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

Improve formatting of Processing Instructions #240

Closed
anthonyvdotbe opened this issue Apr 18, 2020 · 5 comments · Fixed by eclipse-lemminx/lemminx#670
Closed

Improve formatting of Processing Instructions #240

anthonyvdotbe opened this issue Apr 18, 2020 · 5 comments · Fixed by eclipse-lemminx/lemminx#670
Assignees
Labels
enhancement New feature or request formatting
Milestone

Comments

@anthonyvdotbe
Copy link

The formatter formats an XML declaration as follows:

<?xml version="1.0" encoding="UTF-8" ?>

But tools such as Maven generate XML files with an XML declaration as follows (i.e. without a trailing space before the closing tag):

<?xml version="1.0" encoding="UTF-8"?>

This is particularly annoying, because the XML declaration is constantly changed: to version B each time Maven rewrites the XML file (e.g. when doing a release), and then again to version A when the formatter formats the file.

So I think the best option is to format XML declarations as follows:

  • if there's already trailing whitespace before the closing tag, collapse it to a single space character
  • else, don't add any whitespace
@angelozerr
Copy link
Contributor

I'm fine with this suggestion. @fbricon what do you think?

@fbricon
Copy link
Collaborator

fbricon commented Apr 22, 2020

how about xml.format.spaceAfterAttribute or xml.format.spaceAfterLastAttribute?

@fbricon fbricon added this to the 0.12.0 milestone Apr 22, 2020
@fbricon fbricon changed the title Improve formatting of XML declarations Improve formatting of Processing Instructions Apr 22, 2020
@angelozerr
Copy link
Contributor

After discussion, we should never generate a space before the end of processing instruction. If some user will need that, we will introduce a new settings for that like @fbricon suggested. But for the moment keep simply and don't generate this extra space.

@anthonyvdotbe
Copy link
Author

Sounds good to me, thanks.

@angelozerr
Copy link
Contributor

Fixed with eclipse-lemminx/lemminx#670

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request formatting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants