From 2a7a4a80c69c8fa3d13df5daf0958fc98246c538 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 3 Mar 2025 18:51:09 -0700 Subject: [PATCH] Fix toggle fold in deleted hunk (#25967) Updates #25835 Updates #25951 Closes #ISSUE Release Notes: - Fixed toggling folds from within deleted hunks --- crates/editor/src/editor.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 2d51cc47d7..240117e250 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -12965,13 +12965,18 @@ impl Editor { } } else { let multi_buffer_snapshot = self.buffer.read(cx).snapshot(cx); - let buffer_ids: HashSet<_> = multi_buffer_snapshot - .ranges_to_buffer_ranges(self.selections.disjoint_anchor_ranges()) - .map(|(snapshot, _, _)| snapshot.remote_id()) + let buffer_ids: HashSet<_> = self + .selections + .disjoint_anchor_ranges() + .flat_map(|range| multi_buffer_snapshot.buffer_ids_for_range(range)) .collect(); + let should_unfold = buffer_ids + .iter() + .any(|buffer_id| self.is_buffer_folded(*buffer_id, cx)); + for buffer_id in buffer_ids { - if self.is_buffer_folded(buffer_id, cx) { + if should_unfold { self.unfold_buffer(buffer_id, cx); } else { self.fold_buffer(buffer_id, cx);