Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add an action dedicated to closing the sidebar (#51982)
Joseph T. Lyons93a226df0cb7
diff --git a/crates/workspace/src/multi_workspace.rs b/crates/workspace/src/multi_workspace.rsindex 0205ed8a042..2644ad4c620 100644--- a/crates/workspace/src/multi_workspace.rs+++ b/crates/workspace/src/multi_workspace.rs@@ -26,6 +26,8 @@ actions!([/// Toggles the workspace switcher sidebar.ToggleWorkspaceSidebar,+ /// Closes the workspace sidebar.+ CloseWorkspaceSidebar,/// Moves focus to or from the workspace sidebar without closing it.FocusWorkspaceSidebar,]@@ -217,6 +219,16 @@ impl MultiWorkspace {}}+ pub fn close_sidebar_action(&mut self, window: &mut Window, cx: &mut Context<Self>) {+ if !self.multi_workspace_enabled(cx) {+ return;+ }++ if self.sidebar_open {+ self.close_sidebar(window, cx);+ }+ }+pub fn focus_sidebar(&mut self, window: &mut Window, cx: &mut Context<Self>) {if !self.multi_workspace_enabled(cx) {return;@@ -738,6 +750,11 @@ impl Render for MultiWorkspace {this.toggle_sidebar(window, cx);},))+ .on_action(cx.listener(+ |this: &mut Self, _: &CloseWorkspaceSidebar, window, cx| {+ this.close_sidebar_action(window, cx);+ },+ )).on_action(cx.listener(|this: &mut Self, _: &FocusWorkspaceSidebar, window, cx| {this.focus_sidebar(window, cx);diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex da65d8d3cf8..b65fae65568 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -27,8 +27,8 @@ mod workspace_settings;pub use crate::notifications::NotificationFrame;pub use dock::Panel;pub use multi_workspace::{- DraggedSidebar, FocusWorkspaceSidebar, MultiWorkspace, MultiWorkspaceEvent, Sidebar,- SidebarHandle, ToggleWorkspaceSidebar,+ CloseWorkspaceSidebar, DraggedSidebar, FocusWorkspaceSidebar, MultiWorkspace,+ MultiWorkspaceEvent, Sidebar, SidebarHandle, ToggleWorkspaceSidebar,};pub use path_list::{PathList, SerializedPathList};pub use toast_layer::{ToastAction, ToastLayer, ToastView};