Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added closingBracketNewLine option #1051

Merged
merged 1 commit into from
Jun 17, 2021
Merged

Conversation

AlexXuChen
Copy link
Contributor

@AlexXuChen AlexXuChen commented Jun 8, 2021

Added formatting option to put XML closing tagbracket on newline.

Closes redhat-developer/vscode-xml#435

Signed-off-by: Alexander Chen [email protected]

@AlexXuChen
Copy link
Contributor Author

test this please

1 similar comment
@datho7561
Copy link
Contributor

test this please

package-lock.json Outdated Show resolved Hide resolved
@AlexXuChen
Copy link
Contributor Author

Changes to package.json on vscode-xml: redhat-developer/vscode-xml/pull/508

Copy link
Contributor

@datho7561 datho7561 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a case that isn't working as expected:

<aaa>
  <bbb attr1="value" attr2="value" />
</aaa>

When you format with the setting enabled, you would expect the end of the tag /> to be indented to the same level as the start of the tag <bbb. Instead, you get:

<aaa>
  <bbb
      attr1="value"
      attr2="value"
/>
</aaa>

It would be good to fix this case, and add a unit test for it.

@AlexXuChen
Copy link
Contributor Author

AlexXuChen commented Jun 15, 2021

Another small clarification about behaviour, similar to your comment:

if we have:

<aaa>
  <bbb attr1="value" attr2="value">
  </bbb>
</aaa>

along with the previous issue, when formatted, it becomes:

<aaa>
  <bbb 
    attr1="value" 
    attr2="value" 
></bbb>
</aaa>

So not only does the indenting not follow, but the closing bracket is on the same line as the closing tag.

Should this be fixed with my feature, or is this a part of another formatting setting?

*Edit - is this bug related? redhat-developer/vscode-xml/issues/505

**Edit - by enabling preserveEmptyContent, this issue no longer happens. However, the code action bug i see with redhat-developer/vscode-xml/issues/505 remains, even with preserveEmptyContent

@AlexXuChen AlexXuChen changed the title Added closingTagNewLine option Added closingBracketNewLine option Jun 15, 2021
@datho7561
Copy link
Contributor

Should this be fixed with my feature, or is this a part of another formatting setting?

Except for the fact that the > isn't indented properly, this appears to be working as intended. The formatter intentionally removes the white space between the opening and closing tag. If you enable xml.format.preserveEmptyContent, it should keep the white space. If you set xml.format.emptyElements to collapse, it will replace ></bbb> with />

Copy link
Contributor

@datho7561 datho7561 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its working really well, just needs a small improvement in the documentation

@datho7561 datho7561 merged commit ec4a7ae into eclipse:master Jun 17, 2021
@AlexXuChen AlexXuChen deleted the issue435 branch June 17, 2021 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Format XML split attributes with closing tag on new line
2 participants