diff --git a/gpui/src/app.rs b/gpui/src/app.rs index 1e531d3692..a37e6e4157 100644 --- a/gpui/src/app.rs +++ b/gpui/src/app.rs @@ -2857,6 +2857,12 @@ impl Clone for AnyViewHandle { } } +impl From<&AnyViewHandle> for AnyViewHandle { + fn from(handle: &AnyViewHandle) -> Self { + handle.clone() + } +} + impl From<&ViewHandle> for AnyViewHandle { fn from(handle: &ViewHandle) -> Self { handle diff --git a/zed/src/chat_panel.rs b/zed/src/chat_panel.rs index 03630ac6c8..140ddcf28d 100644 --- a/zed/src/chat_panel.rs +++ b/zed/src/chat_panel.rs @@ -214,6 +214,10 @@ impl View for ChatPanel { .with_style(&theme.chat_panel.container) .boxed() } + + fn on_focus(&mut self, cx: &mut ViewContext) { + cx.focus(&self.input_editor); + } } fn format_timestamp(mut timestamp: OffsetDateTime, mut now: OffsetDateTime) -> String { diff --git a/zed/src/workspace.rs b/zed/src/workspace.rs index e5785028a3..2d7f44fd01 100644 --- a/zed/src/workspace.rs +++ b/zed/src/workspace.rs @@ -767,6 +767,11 @@ impl Workspace { Side::Right => &mut self.right_sidebar, }; sidebar.toggle_item(action.0.item_index); + if let Some(active_item) = sidebar.active_item() { + cx.focus(active_item); + } else { + cx.focus_self(); + } cx.notify(); } diff --git a/zed/src/workspace/sidebar.rs b/zed/src/workspace/sidebar.rs index 242b557c39..f0bafd5472 100644 --- a/zed/src/workspace/sidebar.rs +++ b/zed/src/workspace/sidebar.rs @@ -49,7 +49,7 @@ impl Sidebar { if self.active_item_ix == Some(item_ix) { self.active_item_ix = None; } else { - self.active_item_ix = Some(item_ix) + self.active_item_ix = Some(item_ix); } }