sindresorhus / editorconfig-sublime

Sublime Text plugin for EditorConfig - Helps developers maintain consistent coding styles between different editors
MIT License
1.77k stars 108 forks source link

Provide a way to stop trim_trailing_whitespace option to modify entire file on save #94

Open nbenitez opened 2 years ago

nbenitez commented 2 years ago

When you contribute to open source projects you are required to submit patches or PR with just the code changes for the issue you're trying to fix, but, if the .editorconfig file has trim_trailing_whitespace: true (like here) then even if you just change one line code and save, then the file will have lot of whitespace changes due to the mentioned option.

EditorConfig website docs for trim_trailing_whitespace does not mention that the option should affect ALL the file on save, I think it's less intrusive to just remove the trailing whitespace from the lines of code that you're editing (not to all the file on save).

Well, I understand that this option has been working like that for a while, so in order to not change behaviour for existing users, I propose to add a new preference option like eg. trim_trailing_whitespace_not_on_save: true which will disable the undesirable effect.

Check out this StackOverflow question as an example of how this is currently affecting users:\ https://stackoverflow.com/questions/43343211/sublime-text-3-is-automatically-converting-spaces-to-tabs-on-save-regardless-of/

jpcirrus commented 2 years ago

According to the EditorConfig specification the description for trim_trailing_whitespace is: "Set to true to remove all whitespace characters preceding newline characters in the file and false to ensure it doesn’t.", which refers to the file not modified lines. So this package is doing the right thing according to the spec. Fortunately, since Sublime Text build 4050, released on 2019-11-13, there is a new setting trim_only_modified_white_space with the default value of true which does what you (and I) want. Prior to that I was using the TrailingSpaces package which could be configured to do the same thing.