View | Details | Raw Unified | Return to bug 294631
Collapse All | Expand All

(-)formatter/org/eclipse/jdt/internal/formatter/Scribe.java (-5 / +3 lines)
Lines 3536-3543 Link Here
3536
3536
3537
		// Insert last gap
3537
		// Insert last gap
3538
	    boolean closingTag = isHtmlBreakTag || (text.htmlIndexes != null && (text.htmlIndexes[max] & JAVADOC_TAGS_ID_MASK) == htmlTagID);
3538
	    boolean closingTag = isHtmlBreakTag || (text.htmlIndexes != null && (text.htmlIndexes[max] & JAVADOC_TAGS_ID_MASK) == htmlTagID);
3539
		boolean isValidHtmlSeparatorTag = max > 0 && isHtmlSeparatorTag && closingTag;
3539
		if (previousEnd != -1) {
3540
		if (previousEnd != -1) {
3540
		    if (max > 0 && isHtmlSeparatorTag && closingTag) {
3541
		    if (isValidHtmlSeparatorTag) {
3541
				if (linesAfter == 0) linesAfter = 1;
3542
				if (linesAfter == 0) linesAfter = 1;
3542
			}
3543
			}
3543
			if (linesAfter > 0) {
3544
			if (linesAfter > 0) {
Lines 3563-3572 Link Here
3563
		this.scanner.resetTo(text.sourceEnd+1, this.scannerEndPosition - 1);
3564
		this.scanner.resetTo(text.sourceEnd+1, this.scannerEndPosition - 1);
3564
3565
3565
		// Return the new lines to insert after
3566
		// Return the new lines to insert after
3566
	    if (max > 0 && isHtmlSeparatorTag) {
3567
	    return isValidHtmlSeparatorTag ? 1 : 0;
3567
			return 1;
3568
		}
3569
	    return 0;
3570
    }
3568
    }
3571
3569
3572
	private void printJavadocNewLine(StringBuffer buffer) {
3570
	private void printJavadocNewLine(StringBuffer buffer) {
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java (+38 lines)
Lines 1568-1571 Link Here
1568
	DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences);
1568
	DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences);
1569
	assertEquals("wrong indentation string", org.eclipse.jdt.internal.compiler.util.Util.EMPTY_STRING, codeFormatter.createIndentationString(0));
1569
	assertEquals("wrong indentation string", org.eclipse.jdt.internal.compiler.util.Util.EMPTY_STRING, codeFormatter.createIndentationString(0));
1570
}
1570
}
1571
1572
/**
1573
 * @bug 294631: [formatter] The formatter takes two passes to format a common sequence of html tags
1574
 * @test Verify that the specific sequence of html tags is well formatted in one pass
1575
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=294631"
1576
 */
1577
public void testBug294631() {
1578
	String source =
1579
		"package wkps3;\n" + 
1580
		"\n" + 
1581
		"/**\n" + 
1582
		" * This comment makes the formatter unstable:\n" + 
1583
		" * \n" + 
1584
		" * <ol>\n" + 
1585
		" *   <li><p> first line\n" + 
1586
		" *   second line</li>\n" + 
1587
		" * </ol>\n" + 
1588
		" */\n" + 
1589
		"public class X {\n" + 
1590
		"\n" + 
1591
		"}\n";
1592
	formatSource(source,
1593
		"package wkps3;\n" + 
1594
		"\n" + 
1595
		"/**\n" + 
1596
		" * This comment makes the formatter unstable:\n" + 
1597
		" * \n" + 
1598
		" * <ol>\n" + 
1599
		" * <li>\n" + 
1600
		" * <p>\n" + 
1601
		" * first line second line</li>\n" + 
1602
		" * </ol>\n" + 
1603
		" */\n" + 
1604
		"public class X {\n" + 
1605
		"\n" + 
1606
		"}\n"
1607
	);
1608
}
1571
}
1609
}

Return to bug 294631