Files
zed/crates/workspace
Om ChillureandMrSubidubi d1d1471119 workspace: Fix autosave on buffer change in multibuffer (#50686)
Fixes #50526
Fixes https://github.com/zed-industries/zed/issues/42841
Fixes https://github.com/zed-industries/zed/issues/49875

### Summary

Fix `autosave: on_focus_change` not firing reliably when leaving editors
with nested focus targets (e.g. multibuffer/search flows).

### Root cause

Autosave on focus change was wired to `on_blur` of the item focus
handle.
`on_blur` only fires when that exact handle is the focused leaf, which
misses common descendant-to-outside focus transitions.

## Fix

In `crates/workspace/src/item.rs`, switch autosave subscription from:
     - `cx.on_blur(&self.read(cx).focus_handle(cx), ...)`

to:
     - `cx.on_focus_out(&self.read(cx).focus_handle(cx), ...)`

Autosave behavior and guards remain unchanged:
- only for `AutosaveSetting::OnFocusChange`
- only when focus truly left the item (`!contains_focused`)
- skipped when modal is active (`!has_active_modal`)

### Impact

- Fixes missed autosaves when moving focus from item descendants to
other UI (terminal, file tree, search inputs, etc.).
- No behavior change for other autosave modes (`off`, `after_delay`,
`on_window_change`).

### Video
[Screencast from 2026-03-04
15-23-07.webm](https://github.com/user-attachments/assets/81135999-320f-40f3-9673-7c0460e5a14a)




Release Notes:

- Fixed an issue where `"autosave": "on_focus_change"` would not
reliably work in multibuffers.

---------

Co-authored-by: MrSubidubi <finn@zed.dev>
2026-03-05 09:51:20 +00:00
..