mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
sidebar: Fix focus movement to protect zoomed in panels (#53386)
Follow up to https://github.com/zed-industries/zed/pull/53283. That PR replaced _where_ focus goes — from "always the center pane" to "the saved element." But it didn't fix _when_ focus moves — it still moves every time the sidebar closes, unconditionally. The problem is the saved focus can be wrong... it's saved when the sidebar opens, but then it can go to somewhere else after. An example: 1. Open sidebar → save focus (center pane), focus sidebar 2. Open agent panel from sidebar → focus moves to agent panel 3. Close sidebar → restore saved focus → **focuses center pane** (that's what was saved in step 1, not the agent panel) Effectively, this would still cause the agent panel to auto-dismiss. This PR fixes it by no moving focus at all if the sidebar doesn't have it. If the user already moved focus to the agent panel, there's nothing to "restore". Release Notes: - N/A
This commit is contained in:
parent
ae4404f148
commit
c32a7c1f61
1 changed files with 9 additions and 1 deletions
|
|
@ -491,7 +491,15 @@ impl MultiWorkspace {
|
|||
workspace.set_sidebar_focus_handle(None);
|
||||
});
|
||||
}
|
||||
self.restore_previous_focus(true, window, cx);
|
||||
let sidebar_has_focus = self
|
||||
.sidebar
|
||||
.as_ref()
|
||||
.is_some_and(|s| s.focus_handle(cx).contains_focused(window, cx));
|
||||
if sidebar_has_focus {
|
||||
self.restore_previous_focus(true, window, cx);
|
||||
} else {
|
||||
self.previous_focus_handle.take();
|
||||
}
|
||||
self.serialize(cx);
|
||||
cx.notify();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue