zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
49.44k stars 3.01k forks source link

Editing settings.json with format_on_save: any changes to json formatting options require two saves to apply #16351

Open everdrone opened 2 months ago

everdrone commented 2 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

Only after editing the settings.json file and saving twice the setting for tab_size will be applied.

Environment

Zed: v0.150.0 (Zed Dev f7f5a255845b45ac33ab88bfdc023894034168b7) OS: Windows 10.0.22631 Memory: 63.1 GiB Architecture: x86_64 GPU: NVIDIA GeForce RTX 4090 || NVIDIA || 560.81

If applicable, add mockups / screenshots to help explain present your vision of the feature

https://github.com/user-attachments/assets/808099bf-7ec7-4535-9460-64693df559c1

If applicable, attach your Zed.log file to this issue.

Zed.log


everdrone commented 2 months ago

Possibly related to

notpeter commented 2 months ago

This is funky corner case. Normally you go ctrl-s to save a file, we only do anything if the buffer is dirty (something has changed). If you have format_on_save enabled it will trigger a format before it writes to disk. But it does so with the old formatting settings (tab size). Only on the next reformat (either by getting the buffer marked dirty and saving or manually triggering a format) will it know to use the new settings/

If you want to manually reformat you can trigger Editor: format from the command palette. (ctrl-shift-i on Linux/Windows or cmd-shift-i on Mac).

everdrone commented 2 months ago

Ah I see, makes sense now

SomeoneToIgnore commented 2 months ago

To note, project_panel.auto_fold_dirs setting reliably reproduces this behavior on two different set-ups (https://github.com/zed-industries/zed/discussions/16655#discussioncomment-10419146).