diff --git a/crates/terminal/src/modal.rs b/crates/terminal/src/modal.rs index bf83196a97..63cc4316cf 100644 --- a/crates/terminal/src/modal.rs +++ b/crates/terminal/src/modal.rs @@ -1,6 +1,6 @@ use gpui::{ModelHandle, ViewContext}; use settings::{Settings, WorkingDirectory}; -use workspace::{programs::ProgramManager, Workspace}; +use workspace::{programs::Dock, Workspace}; use crate::{ terminal_container_view::{ @@ -13,7 +13,7 @@ pub fn deploy_modal(workspace: &mut Workspace, _: &DeployModal, cx: &mut ViewCon let window = cx.window_id(); // Pull the terminal connection out of the global if it has been stored - let possible_terminal = ProgramManager::remove::(window, cx); + let possible_terminal = Dock::remove::(window, cx); if let Some(terminal_handle) = possible_terminal { workspace.toggle_modal(cx, |_, cx| { @@ -22,7 +22,7 @@ pub fn deploy_modal(workspace: &mut Workspace, _: &DeployModal, cx: &mut ViewCon }); // Toggle Modal will dismiss the terminal modal if it is currently shown, so we must // store the terminal back in the global - ProgramManager::insert_or_replace::(window, terminal_handle, cx); + Dock::insert_or_replace::(window, terminal_handle, cx); } else { // No connection was stored, create a new terminal if let Some(closed_terminal_handle) = workspace.toggle_modal(cx, |workspace, cx| { @@ -43,7 +43,7 @@ pub fn deploy_modal(workspace: &mut Workspace, _: &DeployModal, cx: &mut ViewCon cx.subscribe(&terminal_handle, on_event).detach(); // Set the global immediately if terminal construction was successful, // in case the user opens the command palette - ProgramManager::insert_or_replace::(window, terminal_handle, cx); + Dock::insert_or_replace::(window, terminal_handle, cx); } this @@ -55,7 +55,7 @@ pub fn deploy_modal(workspace: &mut Workspace, _: &DeployModal, cx: &mut ViewCon let terminal_handle = connected.read(cx).handle(); // Set the global immediately if terminal construction was successful, // in case the user opens the command palette - ProgramManager::insert_or_replace::(window, terminal_handle, cx); + Dock::insert_or_replace::(window, terminal_handle, cx); } } } @@ -69,7 +69,7 @@ pub fn on_event( ) { // Dismiss the modal if the terminal quit if let Event::CloseTerminal = event { - ProgramManager::remove::(cx.window_id(), cx); + Dock::remove::(cx.window_id(), cx); if workspace.modal::().is_some() { workspace.dismiss_modal(cx) diff --git a/crates/workspace/src/programs.rs b/crates/workspace/src/programs.rs index 36169ea4c7..015d37f00e 100644 --- a/crates/workspace/src/programs.rs +++ b/crates/workspace/src/programs.rs @@ -19,27 +19,25 @@ use gpui::{AnyModelHandle, Entity, ModelHandle, View, ViewContext}; /// This struct is going to be the starting point for the 'program manager' feature that will /// eventually be implemented to provide a collaborative way of engaging with identity-having /// features like the terminal. -pub struct ProgramManager { +pub struct Dock { // TODO: Make this a hashset or something modals: HashMap, } -impl ProgramManager { +impl Dock { pub fn insert_or_replace( window: usize, program: ModelHandle, cx: &mut ViewContext, ) -> Option { - cx.update_global::(|pm, _| { - pm.insert_or_replace_internal::(window, program) - }) + cx.update_global::(|pm, _| pm.insert_or_replace_internal::(window, program)) } pub fn remove( window: usize, cx: &mut ViewContext, ) -> Option> { - cx.update_global::(|pm, _| pm.remove_internal::(window)) + cx.update_global::(|pm, _| pm.remove_internal::(window)) } pub fn new() -> Self { diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 643ade23a7..5e010a1d25 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -37,7 +37,7 @@ use log::error; pub use pane::*; pub use pane_group::*; use postage::prelude::Stream; -use programs::ProgramManager; +use programs::Dock; use project::{fs, Fs, Project, ProjectEntryId, ProjectPath, ProjectStore, Worktree, WorktreeId}; use searchable::SearchableItemHandle; use serde::Deserialize; @@ -147,7 +147,7 @@ impl_actions!(workspace, [ToggleProjectOnline, ActivatePane]); pub fn init(app_state: Arc, cx: &mut MutableAppContext) { // Initialize the program manager immediately - cx.set_global(ProgramManager::new()); + cx.set_global(Dock::new()); pane::init(cx);