From 93a226df0cb7c7def50c800044fa5047599f8f2c Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Thu, 19 Mar 2026 22:10:34 -0400 Subject: [PATCH] Add an action dedicated to closing the sidebar (#51982) ## Context This PR adds an action that only closes the sidebar, rather than always toggling. ## Self-Review Checklist - [X] I've reviewed my own diff for quality, security, and reliability - [N/A] Unsafe blocks (if any) have justifying comments - [N/A] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [N/A ] Tests cover the new/changed behavior - [N/A] Performance impact has been considered and is acceptable Release Notes: - Added a `multi workspace: close workspace sidebar` action. --- crates/workspace/src/multi_workspace.rs | 17 +++++++++++++++++ crates/workspace/src/workspace.rs | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/workspace/src/multi_workspace.rs b/crates/workspace/src/multi_workspace.rs index 0205ed8a0429fe69577f4e9afe9db46407703db8..2644ad4c620a57866a910f091954e24c8e4eedb8 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) { + 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) { 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.rs index da65d8d3cf8df55e1a3db42e4ebadf43cb47a3f4..b65fae65568def7198931a167ba1e6c8982ae7a9 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};