From e56b692036ed681fbc1edd756ca5e120a5b4e77a Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Mon, 6 Jan 2025 21:20:32 -0700 Subject: [PATCH] Make expand excerpt apply to all excerpts in selections (#22748) Closes #22720 Release Notes: - `ExpandExcerpts` (`shift+enter` by default) now expands all excerpts that have selected text, rather than just excerpts that contain the end of a selection. --- crates/editor/src/editor.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 11d11fc457..a217cda0f1 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -9109,15 +9109,18 @@ impl Editor { }; self.buffer.update(cx, |buffer, cx| { - buffer.expand_excerpts( - selections - .iter() - .map(|selection| selection.head().excerpt_id) - .dedup(), - lines, - direction, - cx, - ) + let snapshot = buffer.snapshot(cx); + let mut excerpt_ids = selections + .iter() + .flat_map(|selection| { + snapshot + .excerpts_for_range(selection.range()) + .map(|excerpt| excerpt.id()) + }) + .collect::>(); + excerpt_ids.sort(); + excerpt_ids.dedup(); + buffer.expand_excerpts(excerpt_ids, lines, direction, cx) }) }