diff options
author | Marco Stornelli | 2019-03-13 17:06:38 +0000 |
---|---|---|
committer | Marco Stornelli | 2019-07-20 08:18:08 +0000 |
commit | 04350fec0eb5063051144fa63c116fa7e83adb09 (patch) | |
tree | 04777e9d3834e51823d1e2ed081c4782624e8f9a | |
parent | e744550278131f5c6ee3cd98a75bd7aa4b9ad399 (diff) | |
download | org.eclipse.cdt-04350fec0eb5063051144fa63c116fa7e83adb09.tar.gz org.eclipse.cdt-04350fec0eb5063051144fa63c116fa7e83adb09.tar.xz org.eclipse.cdt-04350fec0eb5063051144fa63c116fa7e83adb09.zip |
Bug 376395 - Fix const methods with never join wrapped lines
When at the same time never join wrapped lines and next line
for opening function brace were selected, two tabs were added.
Change-Id: I90f606bf7f8b7bb7e83f3ae85d7cbb9cd0146b97
Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
-rw-r--r-- | core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java | 3 | ||||
-rw-r--r-- | core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java index a50ba70a5bb..ffe73d2a7dd 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java @@ -368,7 +368,8 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, } } else { // Skip the rest (=0) - if (needSpace && scribe.printComment()) { + if (needSpace) { + scribe.printTrailingComment(); scribe.space(); } skipNode(node); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java index 49c01511647..c2c24738834 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java @@ -4444,4 +4444,20 @@ public class CodeFormatterTest extends BaseUITestCase { fOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE, DefaultCodeFormatterConstants.FALSE); assertFormatterResult(); } + + //int foo(int arg1) const + //{ + // return 2; + //} + + //int foo(int arg1) const + //{ + // return 2; + //} + public void testConstMethodsWithNeverJoin_Bug376395() throws Exception { + fOptions.put(DefaultCodeFormatterConstants.FORMATTER_JOIN_WRAPPED_LINES, false); + fOptions.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, + DefaultCodeFormatterConstants.NEXT_LINE); + assertFormatterResult(); + } } |