zed format on save potentially breaks git diff #35228
Replies: 3 comments
-
|
This is a conscious (albeit controversial) design choice. We believe there are real benefits if having a default behavior which enforces a format_on_save with a formatter. You can disable it via setting with: {
"languages": {
"Javascript": {
"format_on_save": "off"
}
}
}Or temporarily use
You should be able to trigger an undo and your original changes (sans formatting) should be retained. There is an existing feature request to only changed diffed lines: |
Beta Was this translation helpful? Give feedback.
-
|
#16509 would be an optimum solution |
Beta Was this translation helpful? Give feedback.
-
I'm not sure you can undo: according to my experimenting, hitting ctl-z actually undo the changes, but when you save with ctl-s the format on save is applied again. Apparently you cannot undo that. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
The autosave feature for js files applies a formatting style without warning the user
Description
https://zed.dev/docs/configuring-zed#format-on-save :
a default format on save without documenting clearly what formatter is used for what language can completely change format and then diffs.
Apparently there no way to recover from the applied format.
Please set default format on save value to off!!!!
Use case:
A file has been modified in another app using a custom format style, say 20 lines modified in a 5000 lines file. Modifications haven't been committed yet. The diff shows the modified lines.
The project is opened in zed, and inadvertetly saved with ctl-s.
Result: almost all the lines are modified! It's impossible to the user to go and identify his original modifications.
Zed Version and System Specs
Zed: v0.196.6 (Zed)
OS: Linux X11 ubuntu 24.04
Memory: 15 GiB
Architecture: x86_64
GPU: AMD Radeon Graphics (RADV RENOIR) || radv || Mesa 24.2.8-1ubuntu1~24.04.1
Beta Was this translation helpful? Give feedback.
All reactions