Autosave blocks format on save
Summary
Autosave makes format on save not work. CMD + S does not count as saving as the autosave is already done and then won't trigger format on save.
Description
Steps to reproduce:
- Do a change in a python file
- Autosave triggers
- CMD + S (save)
Actual: Does NOT trigger formatting
Expected:
- Required: SHOULD trigger formatting
- Optional: SHOULD trigger format on save when auto saving (if configured)
I'm sure this is related since it works if you hit CMD + S:
- Before autosave is triggered
- Or if autosave is disabled
My settings:
click to expand
{
"icon_theme": "VSCode Icons (Dark)",
"theme": "One Dark",
"features": {
"edit_prediction_provider": "zed",
"inline_completions": false,
"show_inline_completions": true
},
"ui_font_size": 14,
"buffer_font_size": 13,
"autosave": {
"after_delay": {
"milliseconds": 1000
}
},
"format_on_save": "on",
"language_overrides": {
"JavaScript": {
"format_on_save": {
"external": {
"command": "/Users/kenny.lindahl/.nvm/versions/node/v18.16.0/bin/prettier",
"arguments": ["--stdin-filepath", "{buffer_path}"]
}
}
}
},
"languages": {
"JavaScript": {
"code_actions_on_format": {
"source.fixAll.eslint": true
}
},
"YAML": {
"formatter": "language_server",
"format_on_save": "on"
},
"Python": {
"language_servers": ["pylsp", "!pyright"],
"formatter": {
"external": {
"command": "/opt/homebrew/bin/ruff",
"arguments": ["format", "--stdin-filename", "{buffer_path}", "-"]
}
},
"format_on_save": "on"
}
},
"lsp": {
"yaml-language-server": {
"command": "/Users/kenny.lindahl/.nvm/versions/node/v20.10.0/bin/yaml-language-server",
"args": ["--stdio"],
"language_ids": ["yaml"],
"settings": {
"yaml": {
"format": {
"enable": true
}
}
}
},
"pylsp": {
"command": "/opt/homebrew/bin/pylsp",
"language_ids": ["python"],
"settings": {
"plugins": {
"flake8": {
"enabled": true,
"executable": "/opt/homebrew/bin/flake8",
"config": "./.flake8"
},
"pycodestyle": { "enabled": false },
"pyflakes": { "enabled": false },
"mccabe": { "enabled": false },
"autopep8": { "enabled": false },
"yapf": { "enabled": false }
}
}
},
"pyright": {
"settings": {
"python.analysis": {
"diagnosticMode": "workspace",
"typeCheckingMode": "off"
}
}
}
},
"project_panel": {
"indent_size": 10
},
"base_keymap": "VSCode"
}
Zed Version and System Specs
Zed: v0.185.9 (Zed) OS: macOS 15.4.1 Memory: 24 GiB Architecture: aarch64
I don't think autoformat on autosave makes very much sense, but I'm open to being convinced otherwise. I do feel, however, that our current behavior of not running format on save if the file is already saved doesn't make sense either, and should probably be changed. For now, I recommend doing editor: format (can bind to a key if you like)
Hi Zed team,
I'm experiencing an issue where the format_on_save option doesn't seem to trigger automatically for JavaScript and React files despite being configured properly.
Here is my full config:
{
"assistant": {
"default_model": {
"provider": "google",
"model": "gemini-2.5-pro-exp-03-25"
},
"version": "2"
},
"ui_font_size": 20,
"buffer_font_size": 17.0,
"theme": {
"mode": "system",
"light": "One Light",
"dark": "One Dark"
},
"autosave": {
"after_delay": {
"milliseconds": 1050
}
},
"format_on_save": "on",
"formatter": "auto",
"languages": {
"JavaScript": {
"format_on_save": "on",
"formatter": "auto"
},
"JSX": {
"format_on_save": "on",
"formatter": "auto"
},
"JavaScriptReact": {
"format_on_save": "on",
"formatter": "auto"
}
}
}
Expected behavior: Code should automatically format when autosave is triggered (after ~1 second of inactivity).
Actual behavior: Code formatting only occurs when I explicitly press Ctrl+S. Autosave does save the file but doesn't format it.
Is this expected behavior? If not, could this be a bug with how autosave and format_on_save interact?
Thanks for the awesome editor!
Hi @KennyLindahl i have the same problem her and i notice it from several days, the first time i ignore it, but now my code base is growing and i think that it is so annoying that the auto-save blocking the auto-formatting.
@probably-neb The optional part is separate from the main bug report, but it's related. You may discuss this internally if you want to.
The required part however is still important to fix i believe. I'm pretty sure this worked before.
Thanks for the suggestion, i might use the key binding for now as a work around.
Looks like duplicate of https://github.com/zed-industries/zed/issues/16588
Seems it is, thanks @mati865