zed icon indicating copy to clipboard operation
zed copied to clipboard

Vim Mode `:w` interferes with format-on-save & autosave on focus loss

Open Sushisource opened this issue 8 months ago • 1 comments

Summary

When using :w to save in vim mode, the : triggers the vim command modal, which causes the buffer to save, which formats, and then the vim save command interferes with the newly-written buffer.

Description

I have seen this with both Python & ruff, and with Typescript/prettier. The behavior is timing sensitive. If you do the :w fast enough, or slow enough, things work. You seemingly have to time it such that you wait for the auto-format to happen after you type : but then you need to do w<enter> immediately after that.

Steps to reproduce:

  1. Use the "autosave": "on_focus_change" setting along with "format_on_save": "on" for any language server
  2. Try to save a buffer with :w
  3. You can trigger a "This file has changed on disk since you started editing it..."

Expected Behavior: No saving conflicts Actual Behavior: Saving conflicts

Zed Version and System Specs

Zed: v0.181.5 (Zed) OS: Linux Wayland arch unknown Memory: 62.6 GiB Architecture: x86_64 GPU: NVIDIA GeForce RTX 2070 SUPER || NVIDIA || 570.133.07

Sushisource avatar Apr 15 '25 00:04 Sushisource

~~I made some changes to this area that were released soon after you opened this issue. Could you please confirm that the issue is still occurring? I've tried for a bit to reproduce and haven't been able to thus far, not sure if that's because it's fixed or because I'm not getting the timing right.~~

I've left the setting on and ran into this a couple times now over the past 24 hours. Marking as reproducible. Thanks for reporting!

probably-neb avatar May 20 '25 15:05 probably-neb

Hi there! 👋 We're working to clean up our issue tracker by closing older bugs that might not be relevant anymore. If you are able to reproduce this issue in the latest version of Zed, please let us know by commenting on this issue, and it will be kept open. If you can't reproduce it, feel free to close the issue yourself. Otherwise, it will close automatically in 14 days. Thanks for your help!

github-actions[bot] avatar Nov 19 '25 11:11 github-actions[bot]

It appears this can still happen. At minimum, the command modal causes auto-format to happen still

Sushisource avatar Nov 20 '25 20:11 Sushisource