debugger: Remember focused item (#30722)

Release Notes:

- Debugger Beta: the `debug panel: toggle focus` action now preserves
the debug panel's focused item.
This commit is contained in:
Cole Miller 2025-05-19 17:45:37 +02:00 committed by GitHub
parent d9f12879e2
commit e48daa92c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 57 additions and 19 deletions

View file

@ -2776,10 +2776,17 @@ impl Workspace {
/// Focus the panel of the given type if it isn't already focused. If it is
/// already focused, then transfer focus back to the workspace center.
pub fn toggle_panel_focus<T: Panel>(&mut self, window: &mut Window, cx: &mut Context<Self>) {
pub fn toggle_panel_focus<T: Panel>(
&mut self,
window: &mut Window,
cx: &mut Context<Self>,
) -> bool {
let mut did_focus_panel = false;
self.focus_or_unfocus_panel::<T>(window, cx, |panel, window, cx| {
!panel.panel_focus_handle(cx).contains_focused(window, cx)
did_focus_panel = !panel.panel_focus_handle(cx).contains_focused(window, cx);
did_focus_panel
});
did_focus_panel
}
pub fn activate_panel_for_proto_id(
@ -2813,7 +2820,7 @@ impl Workspace {
&mut self,
window: &mut Window,
cx: &mut Context<Self>,
should_focus: impl Fn(&dyn PanelHandle, &mut Window, &mut Context<Dock>) -> bool,
mut should_focus: impl FnMut(&dyn PanelHandle, &mut Window, &mut Context<Dock>) -> bool,
) -> Option<Arc<dyn PanelHandle>> {
let mut result_panel = None;
let mut serialize = false;