tab_switcher: Add support for tab switcher in terminal panel (#9963)
tab switcher retrieves active pane from workspace, but that function is not aware of Terminal Panel's pane. Thus in this PR we retrieve it manually and use it as the active pane if terminal panel has focus. Release Notes: - Fixed tab switcher not working in terminal panel.
This commit is contained in:
Generated
+1
@@ -9603,6 +9603,7 @@ dependencies = [
|
||||
"project",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"terminal_view",
|
||||
"theme",
|
||||
"ui",
|
||||
"util",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -591,6 +591,9 @@ impl TerminalPanel {
|
||||
|
||||
Some(())
|
||||
}
|
||||
pub fn pane(&self) -> &View<Pane> {
|
||||
&self.pane
|
||||
}
|
||||
}
|
||||
|
||||
async fn wait_for_terminals_tasks(
|
||||
|
||||
Reference in New Issue
Block a user