sindresorhus / atom-editorconfig

Helps developers maintain consistent coding styles between different editors
https://atom.io/packages/editorconfig
MIT License
812 stars 80 forks source link

Newlines removed when insert_final_newline and trim_trailing_whitespace are false. #164

Closed glennpratt closed 7 years ago

glennpratt commented 7 years ago

If manynewlines.txt contains many final new lines, it is reduced to one or zero based on the value of insert_final_newline.

If insert_final_newline is false, I would prefer nothing changes.

Involved .editorconfig-files

root = true

[*]
insert_final_newline = true
trim_trailing_whitespace = false

Directory structure

$ tree -a
.
├── .editorconfig
└── manynewlines.txt

Installed packages

https://gist.github.com/glennpratt/10ff1ae0da0d5710f52b893ef62b322c
glennpratt commented 7 years ago

Ping @florianb

florianb commented 7 years ago

Thanks @glennpratt - this is again one of the interpretable properties of editorconfig.

The current implementation imitates the behaviour of Atom's whitespace package. You probably agree that I am careful in changing behaviour due to single user requests.

In my opinion the editorconfig-standard leaves far too much room for interpretations. I will think about if this property should behave differently and which behaviour is common.

Until this is changed you can disable this property by setting it to an invalid value or commenting it out.

I am sorry I don't have a better answer yet..

glennpratt commented 7 years ago

Thanks! That workaround would not have occurred to me. I wonder if a 'disabled' flag is what's needed in the editorconfig-standard?

For others, something like this worked for me if you need newlines in certain files (or in a subdirectory):

root = true

[*]
insert_final_newline = true
trim_trailing_whitespace = true

[*.txt]
insert_final_newline = invalid_value_to_disable_this
glennpratt commented 7 years ago

editorconfig/editorconfig#282

glennpratt commented 7 years ago

Closing this as the issue seems to lie with the standard. See link above.