From cfe4f5465354b39947c834d252f93620c61fcae8 Mon Sep 17 00:00:00 2001 From: Smit Barmase Date: Thu, 9 Apr 2026 13:02:34 +0530 Subject: [PATCH] skip redudant excerpts check per match --- crates/editor/src/items.rs | 3 +-- crates/multi_buffer/src/multi_buffer.rs | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 1d9516245557af7f84528290b5fb9540d15bb78e..4f81ac59f2ae0a6492929d8f039cbc837a1bb7f4 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -1896,8 +1896,7 @@ impl SearchableItem for Editor { let end = search_buffer.anchor_before( search_range.start + match_range.end, ); - buffer - .buffer_anchor_range_to_anchor_range(start..end) + buffer.anchor_range_in_buffer(start..end) } }) .collect::>(); diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rs index febdc037379dac431c63afa02163cbd092c5cd13..d66e3dfa403b362179896bfc54379f4666b8aa92 100644 --- a/crates/multi_buffer/src/multi_buffer.rs +++ b/crates/multi_buffer/src/multi_buffer.rs @@ -5262,6 +5262,16 @@ impl MultiBufferSnapshot { Some(Anchor::in_buffer(path_key_index, anchor)) } + /// Lifts a buffer anchor range to a multibuffer anchor range without checking against excerpt boundaries. Returns `None` if there are no excerpts for the buffer. + pub fn anchor_range_in_buffer(&self, range: Range) -> Option> { + if range.start.buffer_id != range.end.buffer_id { + return None; + } + + let path_key_index = self.path_key_index_for_buffer(range.start.buffer_id)?; + Some(Anchor::range_in_buffer(path_key_index, range)) + } + /// Creates a multibuffer anchor for the given buffer anchor, if it is contained in any excerpt. pub fn anchor_in_excerpt(&self, text_anchor: text::Anchor) -> Option { for excerpt in {