Closed johnm closed 1 month ago
There's definitely something going awry here. Will bring this up with the team.
Hey @johnm, the remove_trailing_whitespace_on_save
setting only applies to the end of each line (that setting probably needs a more specific name). If you want to tell Zed to stop normalizing newlines at the end of your file to a single newline, you can use "ensure_final_newline_on_save": false
.
Oh, that’s very confusing. To me, ensure_final_newline_on_save is about making sure files which terminate without a newline at the end the final line in the file has one. That’s separate from the “trim_empty_lines_at_the_end_of_the_file” capability that I’m seeing.
On May 22, 2023, at 10:49, Joseph T. Lyons @.***> wrote: Hey @johnm https://github.com/johnm, the remove_trailing_whitespace_on_save setting only applies to the end of each line. If you want to tell Zed to stop normalizing newlines at the end of your file, you can use "ensure_final_newline_on_save": false.
— Reply to this email directly, view it on GitHub https://github.com/zed-industries/zed/issues/4737, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAACDVL4SEVZ22XCU43KFY3XHORJBANCNFSM6AAAAAAYI3PQLU. You are receiving this because you were mentioned.
Yeah, we have two settings. remove_trailing_whitespace_on_save
is about whitespace at the ends of lines, and ensure_final_newline_on_save
is about blank lines at the end of a file. Maybe we need to tweak the names or docs to make this more clear?
Or do we need to break it down into more distinct settings, in order to support your workflow?
For comparison, VS Code seems to have three distinct settings for this:
Note that the current behavior is also broken when I add whitespace to those empty lines at the end of the file (so the behavior isn't even consistent :-( ).
I don't understand what's broken. Can you clarify if there's a bug here, or if you're requesting an additional setting / docs change?
Yes, making the documentation clear would be great. But that also brings up the meta-issue that I seem to be pointing out: Zed has numerous default settings which modify our files without our (the users’) active approval. I.e., zed makes these opt-out rather than opt-in.
Personally, I think that’s the wrong bias for the default settings but be that as it may, all of the code modifying settings should be very clearly listed together somewhere so that people like myself can easily find and change those settings.
In terms of the actual behavior fix for Zed, it sounds like the 3 settings you mention that vscode has it right: trimTrailingWhitespace — only trim extra whitespace at the end of lines trimFinalNewlines — trim any extra empty lines at the end of files insertFinalNewline — aka ensureFinalNewline — make sure that the file ends with a newline, insert one at the end of file if necessary
zed-industries/community#1 & zed-industries/zed#5381 should be implemented in that order. zed-industries/zed#5398 is order independent relative to 1 & 2.
My workflow where the current Zed behavior is painful for me is that I have auto_save turned on. So, I’m in the middle of editing and adding a bunch of code and whenever I stop typing for a few seconds, Zed is overzealously trimming the extra lines in the file. Basically, the settings I want is: trim_trailing_whitespace_on_save = true, ensure_final_newline = true, and trim_final_newlines = false.
On May 31, 2023, at 17:00, Max Brunsfeld @.***> wrote:
Yeah, we have two settings. remove_trailing_whitespace_on_save is about whitespace at the ends of lines, and ensure_final_newline_on_save is about blank lines at the end of a file. Maybe we need to tweak the names or docs to make this more clear?
Or do we need to break it down into more distinct settings, in order to support your workflow?
For comparison, VS Code seems to have three distinct settings for this:
files.trimTrailingWhitespace files.trimFinalNewlines files.insertFinalNewline Note that the current behavior is also broken when I add whitespace to those empty lines at the end of the file (so the behavior isn't even consistent :-( ).
I don't understand what's broken. Can you clarify if there's a bug here, or if you're requesting an additional setting / docs change?
— Reply to this email directly, view it on GitHub https://github.com/zed-industries/zed/issues/4737, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAACDVKZBDIM36PXN26LB2LXI7LQJANCNFSM6AAAAAAYI3PQLU. You are receiving this because you were mentioned.
Hi there! 👋 We're working to clean up our issue tracker by closing older issues that might not be relevant anymore. Are you able to reproduce this issue in the latest version of Zed? If so, please let us know by commenting on this issue and we will keep it open; otherwise, we'll close it in a week. Feel free to open a new issue if you're seeing this message after the issue has been closed. Thanks for your help!
This issue was closed due to inactivity; feel free to open a new issue if you're still experiencing this problem!
Check for existing issues
Describe the bug / provide steps to reproduce it
Changed "remove_trailing_whitespace_on_save" to false in settings.json. Saved settings file.
Added empty lines to a markdown file, I'm in the process of writing. Saved the markdown file. All but the last empty line are deleted in the file.
Added a language section override for the Markdown language for this. Didn't fix it.
Added extra empty lines to other file types such as .gitignore, the settings.json file itself, etc. They all have all of the same behavior.
Tried exiting and restarting Zed. Didn't fix it.
So, this feature only applies to whitespace at the end of non-empty lines.
Note that the current behavior is also broken when I add whitespace to those empty lines at the end of the file (so the behavior isn't even consistent :-( ).
Please stop changing my files in various ways without my permission (and no way to make it stop). :-(
Environment
Zed: v0.86.1 (stable) OS: macOS 12.6.2 Memory: 32 GiB Architecture: aarch64
If applicable, add mockups / screenshots to help explain present your vision of the feature
No response
If applicable, attach your
~/Library/Logs/Zed/Zed.log
file to this issue.If you only need the most recent lines, you can run the
zed: open log
command palette action to see the last 1000.No response