From 46f1d5f5c24448abb2dc149689f389b4378858f8 Mon Sep 17 00:00:00 2001 From: Julia Date: Thu, 1 Dec 2022 00:29:58 -0500 Subject: [PATCH] Avoid moving tab when leader item updates --- crates/workspace/src/workspace.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 7082b61949fd468b9e84795aa39ac135c992ecb8..25fa3654d71c10b5738b39b4a119bcf13a2e6a25 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -2676,7 +2676,12 @@ impl Workspace { } for (pane, item) in items_to_add { - Pane::add_item(self, &pane, item.boxed_clone(), false, false, None, cx); + if let Some(index) = pane.update(cx, |pane, _| pane.index_for_item(item.as_ref())) { + pane.update(cx, |pane, cx| pane.activate_item(index, false, false, cx)); + } else { + Pane::add_item(self, &pane, item.boxed_clone(), false, false, None, cx); + } + if pane == self.active_pane { pane.update(cx, |pane, cx| pane.focus_active_item(cx)); }