amp icon indicating copy to clipboard operation
amp copied to clipboard

Amp silently removes trailing spaces at end of line

Open multinormal opened this issue 3 years ago • 3 comments

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).

multinormal avatar Apr 14 '21 11:04 multinormal

"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.

jmacdonald avatar Apr 17 '21 16:04 jmacdonald

I believe #116 allows you to add trim_trailing_whitespace option not only in .editorconfig files but also in your amp configuration.

x4e avatar Apr 17 '21 18:04 x4e

@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

soloturn avatar Jul 17 '21 14:07 soloturn