Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Matela2020-01-15 14:27:09 -0500
committerMateusz Matela2020-01-15 14:29:23 -0500
commitd5bebfcd41e40e691236ae672f0c877a727409c1 (patch)
tree85a3da5ab0079df2649bfed626ccb61dd53122fa
parent28782a7c8ade50be5fbb2ca2069a38cad29fd355 (diff)
downloadeclipse.jdt.core-d5bebfcd41e40e691236ae672f0c877a727409c1.tar.gz
eclipse.jdt.core-d5bebfcd41e40e691236ae672f0c877a727409c1.tar.xz
eclipse.jdt.core-d5bebfcd41e40e691236ae672f0c877a727409c1.zip
Bug 559006 - [formatter] Wrong indentation in region after wrapped line
Change-Id: I7966f0fbe84399598f912846302b7170fbcdb7b0 Signed-off-by: Mateusz Matela <mateusz.matela@gmail.com>
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java21
-rw-r--r--org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java2
2 files changed, 23 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
index 26bab5ad44..3bbf65b3d0 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
@@ -13085,4 +13085,25 @@ public void testBug250656() {
" }\n" +
"}");
}
+/**
+ * https://bugs.eclipse.org/559006 - [formatter] Wrong indentation in region after wrapped line
+ */
+public void testBug559006() {
+ this.formatterPrefs.page_width = 50;
+ formatSource(
+ "class C {\n" +
+ " void f() {\n" +
+ " doSomething(aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbb,\n" +
+ " + ccccccccccccccccccc);\n" +
+ "[# doSomethingElse();#]\n" +
+ " }\n" +
+ "}",
+ "class C {\n" +
+ " void f() {\n" +
+ " doSomething(aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbb,\n" +
+ " + ccccccccccccccccccc);\n" +
+ " doSomethingElse();\n" +
+ " }\n" +
+ "}");
+}
}
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java
index 6c96bd92dc..0d74d61f99 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/LineBreaksPreparator.java
@@ -818,6 +818,8 @@ public class LineBreaksPreparator extends ASTVisitor {
return false; // must be handling ast rewrite
if (previous != null && this.tm.countLineBreaksBetween(previous, token) == 0)
return false;
+ if (token.getLineBreaksBefore() == 0 && (previous == null || previous.getLineBreaksAfter() == 0))
+ return false;
int lineStart = token.originalStart;
char c;
while (lineStart > 0 && (c = this.tm.charAt(lineStart - 1)) != '\r' && c != '\n')

Back to the top