diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 1e9358b80b8346c6cc0a794820e51b04e7ffde96..0dfd5b2a1c1d4e3027d2d9ed099be5cb2ffbd4d0 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -399,7 +399,12 @@ pub struct Save { pub save_intent: Option, } -/// Closes all items and panes in the workspace. +/// Moves Focus to the central panes in the workspace. +#[derive(Clone, Debug, PartialEq, Eq, Action)] +#[action(namespace = workspace)] +pub struct FocusCenterPane; + +/// Closes all items and panes in the workspace. #[derive(Clone, PartialEq, Debug, Deserialize, Default, JsonSchema, Action)] #[action(namespace = workspace)] #[serde(deny_unknown_fields)] @@ -3824,6 +3829,14 @@ impl Workspace { did_focus_panel } + pub fn focus_center_pane(&mut self, window: &mut Window, cx: &mut Context) { + if let Some(item) = self.active_item(cx) { + item.item_focus_handle(cx).focus(window, cx); + } else { + log::error!("Could not find a focus target when switching focus to the center panes",); + } + } + pub fn activate_panel_for_proto_id( &mut self, panel_id: PanelId, @@ -6852,6 +6865,9 @@ impl Workspace { } }), ) + .on_action(cx.listener(|workspace, _: &FocusCenterPane, window, cx| { + workspace.focus_center_pane(window, cx); + })) .on_action(cx.listener(Workspace::cancel)) }