Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
tab_switcher: Add support for tab switcher in terminal panel (#9963)
Piotr Osiewiczed5bfcdddcdc
diff --git a/Cargo.lock b/Cargo.lockindex 5da1c0c48a9..27fc366f179 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.tomlindex 83d6e20e61d..b67c4a3bf11 100644--- a/crates/tab_switcher/Cargo.toml+++ b/crates/tab_switcher/Cargo.toml@@ -15,6 +15,7 @@ gpui.workspace = truemenu.workspace = truepicker.workspace = trueserde.workspace = true+terminal_view.workspace = trueui.workspace = trueutil.workspace = trueworkspace.workspace = truediff --git a/crates/tab_switcher/src/tab_switcher.rs b/crates/tab_switcher/src/tab_switcher.rsindex 0e444171c0c..d7738ff4a6e 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<Workspace>) {- let weak_pane = workspace.active_pane().downgrade();+ let terminal = workspace.panel::<terminal_view::terminal_panel::TerminalPanel>(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.rsindex ef7c973b75b..89a18820711 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<Pane> {+ &self.pane+ }}async fn wait_for_terminals_tasks(