diff --git a/crates/terminal/src/modal.rs b/crates/terminal/src/modal.rs index 6273ecd5b4..51fc19efa2 100644 --- a/crates/terminal/src/modal.rs +++ b/crates/terminal/src/modal.rs @@ -1,16 +1,18 @@ -use gpui::{ModelHandle, ViewContext, ViewHandle}; +use gpui::{ModelHandle, ViewContext}; use workspace::Workspace; use crate::{get_working_directory, DeployModal, Event, Terminal, TerminalConnection}; +struct StoredConnection(ModelHandle); + pub fn deploy_modal(workspace: &mut Workspace, _: &DeployModal, cx: &mut ViewContext) { // Pull the terminal connection out of the global if it has been stored - let possible_connection = cx - .update_default_global::>, _, _>( - |possible_connection, _| possible_connection.take(), - ); + let possible_connection = + cx.update_default_global::, _, _>(|possible_connection, _| { + possible_connection.take() + }); - if let Some(stored_connection) = possible_connection { + if let Some(StoredConnection(stored_connection)) = possible_connection { // Create a view from the stored connection workspace.toggle_modal(cx, |_, cx| { cx.add_view(|cx| Terminal::from_connection(stored_connection, true, cx)) @@ -31,7 +33,7 @@ pub fn deploy_modal(workspace: &mut Workspace, _: &DeployModal, cx: &mut ViewCon this }) { let connection = closed_terminal_handle.read(cx).connection.clone(); - cx.set_global(Some(connection)); + cx.set_global(Some(StoredConnection(connection))); } } } @@ -44,7 +46,7 @@ pub fn on_event( ) { // Dismiss the modal if the terminal quit if let Event::CloseTerminal = event { - cx.set_global::>>(None); + cx.set_global::>(None); if workspace .modal() .cloned() diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index 4597d3a8a0..1dac9aa7a8 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -319,7 +319,9 @@ impl View for Terminal { fn keymap_context(&self, _: &gpui::AppContext) -> gpui::keymap::Context { let mut context = Self::default_keymap_context(); - context.set.insert("ModalTerminal".into()); + if self.modal { + context.set.insert("ModalTerminal".into()); + } context } }