sidebar: Fix focus movement to protect zoomed in panels (#53386)
Danilo Leal
created
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