Project: JDT
Bug 337150 [typing] Incorrect indentation in string continuation
Reported: 2011-02-14 13:21:02 | Status: verified fixed

HEAD Started with -------------------------------------------------------------------- package p; class A { void foo() { String[] array ={ "this is the 1st string"+ "this is the 1st string"+ "this is the 1st string"+ "this is the 1st string"+ "this is the 1st string", "this is the 2nd string"+ "this is the 2nd string"+ "this is the 2nd string"+ "this is the 2nd string"+ "this is the 2nd string" }; } } --------------------------------------------------------------------- Replace "this is the 2nd string"+ "this is the 2nd string"+ "this is the 2nd string"+ "this is the 2nd string"+ "this is the 2nd string" with "this is the new 2nd string"+ "this is the new 2nd string"+ "this is the new 2nd string"+ "this is the new 2nd string"+ "this is the new 2nd string" => Result is ----------------------------------------------------------------------------- package p; class A { void foo() { String[] array ={ "this is the 1st string"+ "this is the 1st string"+ "this is the 1st string"+ "this is the 1st string"+ "this is the 1st string", "this is the new 2nd string"+ "this is the new 2nd string"+ "this is the new 2nd string"+ "this is the new 2nd string"+ "this is the new 2nd string" }; } } ----------------------------------------------------------------------------- All the lines after the second one are indented by 2. (This works fine if the 1st string is replaced) The concrete use case can be seen in org.eclipse.jdt.core.tests.compiler.regression.JavadocBugsTest.testBug128954(). Thanks Olivier for pointing this out.

Files changed in fix:
org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaAutoIndentStrategyTest.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.java