Skip to content

Consider removing xml.format.preserveEmptyContent for experimental formatter #1346

@JessicaJHee

Description

@JessicaJHee

The experimental formatter introduces a new element category called preserve space, which preserves all white spaces within the specified element tag. Currently, when preserveEmptyContent = true, it has the same behavior as preserve space, making this setting redundant.

Note: consider its behavior when used alongside with other settings:

https://github.com/redhat-developer/vscode-xml/blob/main/docs/Formatting.md#xmlformatpreservednewlines

  • preservedNewLines: this setting is already prioritized over preserveEmptyContent, it's behavior would be unaffected with the removal of preserveEmptyContent. It formats the xml nicely while allowing the user to set a specified number of new lines they would like to keep.

Example:
Before with preservedNewLines = 2:

<foo>

test1           test2


    test3
</foo>

After:

<foo>

    test1 test2


    test3
</foo>

https://github.com/redhat-developer/vscode-xml/blob/main/docs/Formatting.md#xmlformatjoincontentlines

  • joinContentLines If an user wants to normalize the white spaces with in an empty tag, they can use xml.format.joinContentLines instead, which currently has lower priority compared to preserveEmptyContent and the preserve space category.

Example:
Before with joinContentLines = true and preserveEmptyContent = false:

<a>

</a>

After:

<a> </a>

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestformattingThis issue or enhancement is related to formatting support

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions