### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: formatter/org/eclipse/jdt/internal/formatter/Scribe.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java,v retrieving revision 1.179 diff -u -r1.179 Scribe.java --- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 5 Nov 2009 17:41:08 -0000 1.179 +++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 9 Nov 2009 22:04:13 -0000 @@ -3536,8 +3536,9 @@ // Insert last gap boolean closingTag = isHtmlBreakTag || (text.htmlIndexes != null && (text.htmlIndexes[max] & JAVADOC_TAGS_ID_MASK) == htmlTagID); + boolean isValidHtmlSeparatorTag = max > 0 && isHtmlSeparatorTag && closingTag; if (previousEnd != -1) { - if (max > 0 && isHtmlSeparatorTag && closingTag) { + if (isValidHtmlSeparatorTag) { if (linesAfter == 0) linesAfter = 1; } if (linesAfter > 0) { @@ -3563,10 +3564,7 @@ this.scanner.resetTo(text.sourceEnd+1, this.scannerEndPosition - 1); // Return the new lines to insert after - if (max > 0 && isHtmlSeparatorTag) { - return 1; - } - return 0; + return isValidHtmlSeparatorTag ? 1 : 0; } private void printJavadocNewLine(StringBuffer buffer) { #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java,v retrieving revision 1.6 diff -u -r1.6 FormatterBugsTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 5 Nov 2009 17:41:02 -0000 1.6 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 9 Nov 2009 22:04:19 -0000 @@ -1568,4 +1568,42 @@ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); assertEquals("wrong indentation string", org.eclipse.jdt.internal.compiler.util.Util.EMPTY_STRING, codeFormatter.createIndentationString(0)); } + +/** + * @bug 294631: [formatter] The formatter takes two passes to format a common sequence of html tags + * @test Verify that the specific sequence of html tags is well formatted in one pass + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=294631" + */ +public void testBug294631() { + String source = + "package wkps3;\n" + + "\n" + + "/**\n" + + " * This comment makes the formatter unstable:\n" + + " * \n" + + " *
    \n" + + " *
  1. first line\n" + + " * second line

  2. \n" + + " *
\n" + + " */\n" + + "public class X {\n" + + "\n" + + "}\n"; + formatSource(source, + "package wkps3;\n" + + "\n" + + "/**\n" + + " * This comment makes the formatter unstable:\n" + + " * \n" + + " *
    \n" + + " *
  1. \n" + + " *

    \n" + + " * first line second line

  2. \n" + + " *
\n" + + " */\n" + + "public class X {\n" + + "\n" + + "}\n" + ); +} }