Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Hide other panels when clicking on sidebar threads (#52804)

Mikayla Makid22a39f84d4c
diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rs
index a2e0a50abc0..6d7be34ab53 100644
--- a/crates/sidebar/src/sidebar.rs
+++ b/crates/sidebar/src/sidebar.rs
@@ -1999,7 +1999,7 @@ impl Sidebar {
cx: &mut App,
) {
workspace.update(cx, |workspace, cx| {
- workspace.open_panel::<AgentPanel>(window, cx);
+ workspace.reveal_panel::<AgentPanel>(window, cx);
});
if let Some(agent_panel) = workspace.read(cx).panel::<AgentPanel>(cx) {
diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs
index e7acf3615e1..fe100182ca0 100644
--- a/crates/workspace/src/workspace.rs
+++ b/crates/workspace/src/workspace.rs
@@ -4187,6 +4187,17 @@ impl Workspace {
}
}
+ /// Open the panel of the given type, dismissing any zoomed items that
+ /// would obscure it (e.g. a zoomed terminal).
+ pub fn reveal_panel<T: Panel>(&mut self, window: &mut Window, cx: &mut Context<Self>) {
+ let dock_position = self.all_docks().iter().find_map(|dock| {
+ let dock = dock.read(cx);
+ dock.panel_index_for_type::<T>().map(|_| dock.position())
+ });
+ self.dismiss_zoomed_items_to_reveal(dock_position, window, cx);
+ self.open_panel::<T>(window, cx);
+ }
+
pub fn close_panel<T: Panel>(&self, window: &mut Window, cx: &mut Context<Self>) {
for dock in self.all_docks().iter() {
dock.update(cx, |dock, cx| {