From 641f5d1107b282127115d812368704b161748cca Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 9 May 2023 17:38:18 +0200 Subject: [PATCH] Ensure `ctrl-`` works in the terminal panel --- crates/terminal_view/src/terminal_panel.rs | 12 +++++++++--- crates/terminal_view/src/terminal_view.rs | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index 90072ea652..d963025f89 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -8,6 +8,10 @@ use settings::{Settings, WorkingDirectory}; use util::ResultExt; use workspace::{dock::Panel, pane, DraggedItem, Pane, Workspace}; +pub fn init(cx: &mut AppContext) { + cx.add_action(TerminalPanel::add_terminal); +} + pub enum Event { Close, } @@ -47,7 +51,9 @@ impl TerminalPanel { let this = this.clone(); cx.window_context().defer(move |cx| { if let Some(this) = this.upgrade(cx) { - this.update(cx, |this, cx| this.add_terminal(cx)); + this.update(cx, |this, cx| { + this.add_terminal(&Default::default(), cx); + }); } }) }, @@ -80,7 +86,7 @@ impl TerminalPanel { } } - fn add_terminal(&mut self, cx: &mut ViewContext) { + fn add_terminal(&mut self, _: &workspace::NewTerminal, cx: &mut ViewContext) { if let Some(workspace) = self.workspace.upgrade(cx) { let working_directory_strategy = cx .global::() @@ -123,7 +129,7 @@ impl View for TerminalPanel { fn focus_in(&mut self, _: gpui::AnyViewHandle, cx: &mut ViewContext) { if self.pane.read(cx).items_len() == 0 { - self.add_terminal(cx) + self.add_terminal(&Default::default(), cx) } } } diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index e3a5153ef3..b318b572b5 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -64,6 +64,7 @@ actions!( impl_actions!(terminal, [SendText, SendKeystroke]); pub fn init(cx: &mut AppContext) { + terminal_panel::init(cx); cx.add_action(TerminalView::deploy); register_deserializable_item::(cx);