From b9e0269991577b051314e62cd9f171168bd81064 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 17 Apr 2024 22:55:20 +0200 Subject: [PATCH] project panel: do not expand collapsed worktrees on "collapse all entries" (#10687) Fixes #10597 Release Notes: - Fixed "project panel: collapse all entries" expanding collapsed worktrees. --- crates/project_panel/src/project_panel.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 5a57fbfbcdf9c985d6ff3dddeead75f4cb50486b..837e563b1c464af6f7cdd20662513c4edaed229b 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -599,7 +599,10 @@ impl ProjectPanel { } pub fn collapse_all_entries(&mut self, _: &CollapseAllEntries, cx: &mut ViewContext) { - self.expanded_dir_ids.clear(); + // By keeping entries for fully collapsed worktrees, we avoid expanding them within update_visible_entries + // (which is it's default behaviour when there's no entry for a worktree in expanded_dir_ids). + self.expanded_dir_ids + .retain(|_, expanded_entries| expanded_entries.is_empty()); self.update_visible_entries(None, cx); cx.notify(); }