amp
amp copied to clipboard
Amp silently removes trailing spaces at end of line
Editing and then saving a file containing lines that end with a space character results in a file where some or all such trailing characters have been removed, even on lines that have not been edited. (I have not had time to explore this behavior in detail, so I do not know if all such lines are altered, if only spaces or other whitespace characters are altered, or if only visited lines are affected.)
If this is correct behavior rather than a bug, this seems overly opinionated — it's not too hard to imagine this behavior introducing difficult-to-diagnose bugs (given spaces are generally invisible).
"Overly opinionated" is kind of the tag line for amp. :smile: Trailing whitespace has always been an anti-pattern in my experience, and the surprise of unrelated changes can always be managed by using partial staging in git. Ensuring a trailing newline is a similar (and admittedly more common) behaviour.
That said, I wouldn't be opposed to making this configurable. The behaviour for both of these is wrapped up in the save command.
I believe #116 allows you to add trim_trailing_whitespace
option not only in .editorconfig
files but also in your amp configuration.
@jmacdonald , editorconfig is nice to solve this issue. two trailing whitespaces in markdown are the same as <br>
so removing them breaks markdown, oother example see here:
https://github.com/microsoft/vscode/issues/1679