Skip to content

Commit

Permalink
changed closingBracketNewLine indent to match splitAttributeIndentSize
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Chen authored and datho7561 committed Jul 15, 2021
1 parent c09eed8 commit 69720e8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Expand Up @@ -559,7 +559,9 @@ private void formatAttributes(DOMElement element) throws BadLocationException {
}
if ((this.sharedSettings.getFormattingSettings().getClosingBracketNewLine() && this.sharedSettings.getFormattingSettings().isSplitAttributes()) && !isSingleAttribute) {
xmlBuilder.linefeed();
xmlBuilder.indent(this.indentLevel);
// Indent by tag + splitAttributesIndentSize to match with attribute indent level
int totalIndent = this.indentLevel + this.sharedSettings.getFormattingSettings().getSplitAttributesIndentSize();
xmlBuilder.indent(totalIndent);
}
}

Expand Down
Expand Up @@ -2937,6 +2937,20 @@ public void testClosingBracketNewLine() throws BadLocationException {
assertFormat(content, expected, settings);
}

@Test
public void testClosingBracketNewLineWithDefaultIndentSize() throws BadLocationException {
SharedSettings settings = new SharedSettings();
settings.getFormattingSettings().setSplitAttributes(true);
settings.getFormattingSettings().setClosingBracketNewLine(true);
settings.getFormattingSettings().setPreserveAttrLineBreaks(true);
String content = "<a b='b' c='c'/>";
String expected = "<a\n" +
" b='b'\n" +
" c='c'\n" +
" />";
assertFormat(content, expected, settings);
}

@Test
public void testClosingBracketNewLineWithoutSplitAttributes() throws BadLocationException {
SharedSettings settings = new SharedSettings();
Expand Down

0 comments on commit 69720e8

Please sign in to comment.