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 2368c0aee5c..b4626fc404e 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 @@ -2032,6 +2032,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, scribe.space(); } } + scribe.printTrailingComment(); if (enumIndent > braceIndent) { scribe.unIndent(); 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 ebd3f2d7d7f..c50177f5475 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 @@ -2737,16 +2737,25 @@ public class CodeFormatterTest extends BaseUITestCase { } //enum SomeEnum { - //FirstValue, // first value comment - //SecondValue // second value comment + //FirstValue,// first value comment + //SecondValue// second value comment + //}; + //enum OtherEnum { + //First,// first value comment + //Second,// second value comment //}; //enum SomeEnum { // FirstValue, // first value comment // SecondValue // second value comment //}; - public void _testEnum() throws Exception { + //enum OtherEnum { + // First, // first value comment + // Second, // second value comment + //}; + public void testEnum() throws Exception { fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE); + fOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_MIN_DISTANCE_BETWEEN_CODE_AND_LINE_COMMENT, "2"); assertFormatterResult(); } }