workspace: Fix autosave on buffer change in multibuffer#50686
Conversation
|
@jrmajor glad my PR fixed 3 issues, thanks for tagging |
MrSubidubi
left a comment
There was a problem hiding this comment.
Thanks for confirming @jrmajor !
This also looks good to me, however, I think we would benefit if we could add a test for this in test_autosave. To be honest, this might be a bit tedious, but I'd really like for us to ensure that we do not ever regress on this again. Could you look into that?
|
Hey @MrSubidubi I was looking into the test for above but landed on a test failure in worksapce that stopping me form testing, was writing test in worskpace > test_autosave can you check it here : #50701 |
|
Thanks for filing this, we are taking a look. |
|
Thanks to @osiewicz , the issue is now fixed on the latest main |
|
Hey @MrSubidubi Added : test_autosave_on_focus_change_in_multibuffer which:
To support this test, Can you check if the test is fine and covers everything |
MrSubidubi
left a comment
There was a problem hiding this comment.
Nice, very good find, fix and test. Thank you!
Fixes #50526
Fixes #42841
Fixes #49875
Summary
Fix
autosave: on_focus_changenot firing reliably when leaving editors with nested focus targets (e.g. multibuffer/search flows).Root cause
Autosave on focus change was wired to
on_blurof the item focus handle.on_bluronly 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:
AutosaveSetting::OnFocusChange!contains_focused)!has_active_modal)Impact
off,after_delay,on_window_change).Video
Screencast.from.2026-03-04.15-23-07.webm
Release Notes:
"autosave": "on_focus_change"would not reliably work in multibuffers.