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

Formatting of newlines at EOF #196

Closed
anthonyvdotbe opened this issue Oct 26, 2019 · 5 comments · Fixed by eclipse-lemminx/lemminx#649
Closed

Formatting of newlines at EOF #196

anthonyvdotbe opened this issue Oct 26, 2019 · 5 comments · Fixed by eclipse-lemminx/lemminx#649
Assignees
Labels
bug Something isn't working formatting
Milestone

Comments

@anthonyvdotbe
Copy link

Given the following xml:

<root>
    <child>value</child>
</root>


There are 2 issues when formatting:

  • first, and most importantly: there's no way to keep a newline at EOF
  • second, formatting is not idempotent: the first time it removes only 1 of the 2 trailing newlines, the second time it removes the remaining trailing newline
@angelozerr
Copy link
Contributor

Indeed WE should have a new settings for that. An interesting features to explore is to try get this settings from editorconfig https://github.com/editorconfig/editorconfig/wiki/Newline-at-End-of-File-Support if thé XML new settings is not defined

@angelozerr
Copy link
Contributor

3.15 LSP specification provides the insertFinalNewline formattings option that we should use to implement this issue. See https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#textDocument_formatting

@angelozerr
Copy link
Contributor

Once eclipse-lemminx/lemminx#628 will be done, we will able to LSP4J FormattingOptions#isInsertFinalNewline()

@ilyvion
Copy link

ilyvion commented Dec 31, 2022

Maybe I'm missing something, but I don't see any setting for preserving/ensuring there's a newline at EOF, and the formatter definitely removes any I add myself. Seeing this issue and it being resolved made me think it was a foregone issue, but clearly it's not? I'm using version 0.23.

EDIT: Never mind, it's not a setting in this extension specifically, but rather under "Text Editor" -> "Files"

@angelozerr
Copy link
Contributor

https://github.com/redhat-developer/vscode-xml/blob/main/docs/Formatting.md#filesinsertfinalnewline should work. If it doesn't work, please create a new issue with your usecase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working formatting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants