diff --git a/Cargo.lock b/Cargo.lock index 5da1c0c48a..27fc366f17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9603,6 +9603,7 @@ dependencies = [ "project", "serde", "serde_json", + "terminal_view", "theme", "ui", "util", diff --git a/crates/tab_switcher/Cargo.toml b/crates/tab_switcher/Cargo.toml index 83d6e20e61..b67c4a3bf1 100644 --- a/crates/tab_switcher/Cargo.toml +++ b/crates/tab_switcher/Cargo.toml @@ -15,6 +15,7 @@ gpui.workspace = true menu.workspace = true picker.workspace = true serde.workspace = true +terminal_view.workspace = true ui.workspace = true util.workspace = true workspace.workspace = true diff --git a/crates/tab_switcher/src/tab_switcher.rs b/crates/tab_switcher/src/tab_switcher.rs index 0e444171c0..d7738ff4a6 100644 --- a/crates/tab_switcher/src/tab_switcher.rs +++ b/crates/tab_switcher/src/tab_switcher.rs @@ -56,7 +56,16 @@ impl TabSwitcher { } fn open(action: &Toggle, workspace: &mut Workspace, cx: &mut ViewContext) { - let weak_pane = workspace.active_pane().downgrade(); + let terminal = workspace.panel::(cx); + let terminal_pane = terminal.and_then(|terminal| { + terminal + .focus_handle(cx) + .contains_focused(cx) + .then(|| terminal.read(cx).pane()) + }); + let weak_pane = terminal_pane + .unwrap_or_else(|| workspace.active_pane()) + .downgrade(); workspace.toggle_modal(cx, |cx| { let delegate = TabSwitcherDelegate::new(action, cx.view().downgrade(), weak_pane, cx); TabSwitcher::new(delegate, cx) diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index ef7c973b75..89a1882071 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -591,6 +591,9 @@ impl TerminalPanel { Some(()) } + pub fn pane(&self) -> &View { + &self.pane + } } async fn wait_for_terminals_tasks(