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

don't remove newline from end of file #131

Open
simonLeary42 opened this issue Aug 1, 2023 · 1 comment
Open

don't remove newline from end of file #131

simonLeary42 opened this issue Aug 1, 2023 · 1 comment
Labels
yaml_v3_problem A bug in the underlying yaml library. These issues are vastly harder to fix.

Comments

@simonLeary42
Copy link

simonLeary42 commented Aug 1, 2023

I might be showing my ignorance, but I was under the assumption that all plain text files should end in a newline, per the posix definition of a file. Why does yamlfmt remove them? How can I tell yamlfmt to not do that?

@braydonk
Copy link
Collaborator

braydonk commented Aug 1, 2023

Hi @simonLeary42 thanks for opening an issue.

This is an issue in the yaml parsing library, which will not retain any newline information in its AST representation. I've tried to fix it but haven't been successful so far.

To keep the newlines at the ends of files, please use the retain_line_breaks configuration option. See https://github.com/google/yamlfmt/blob/main/docs/config-file.md#basic-formatter for more info.

I'll try adding a convenience hack that will add the linebreak back in if retain_line_breaks is turned off.

@braydonk braydonk added the yaml_v3_problem A bug in the underlying yaml library. These issues are vastly harder to fix. label Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
yaml_v3_problem A bug in the underlying yaml library. These issues are vastly harder to fix.
Projects
None yet
Development

No branches or pull requests

2 participants