multi_buffer: Fix handling of ExcerptId::max() (#38887)
This removes a hack from `MultiBuffer::anchor_at` that works around missing logic for handling `ExcerptId::max()` by implementing that said missing logic. Generally, `ExcerptId::min()` is already being handled correctly due to how `Cursor` seeking works, we tend to seek to or beyond a seek target, meaning `min` will always match the first excerpt as expected. `max` on the other hand will always seek beyond the last excerpt resulting in no excerpt being found, so any code path dealing with the excerpt sumtree will have to specially check for this special excerpt ID to work correctly. Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
@@ -578,12 +578,11 @@ fn deserialize_selection(
|
||||
|
||||
fn deserialize_anchor(buffer: &MultiBufferSnapshot, anchor: proto::EditorAnchor) -> Option<Anchor> {
|
||||
let excerpt_id = ExcerptId::from_proto(anchor.excerpt_id);
|
||||
Some(Anchor {
|
||||
Some(Anchor::in_buffer(
|
||||
excerpt_id,
|
||||
text_anchor: language::proto::deserialize_anchor(anchor.anchor?)?,
|
||||
buffer_id: buffer.buffer_id_for_excerpt(excerpt_id),
|
||||
diff_base_anchor: None,
|
||||
})
|
||||
buffer.buffer_id_for_excerpt(excerpt_id)?,
|
||||
language::proto::deserialize_anchor(anchor.anchor?)?,
|
||||
))
|
||||
}
|
||||
|
||||
impl Item for Editor {
|
||||
@@ -1752,13 +1751,8 @@ impl SearchableItem for Editor {
|
||||
.anchor_after(search_range.start + match_range.start);
|
||||
let end = search_buffer
|
||||
.anchor_before(search_range.start + match_range.end);
|
||||
Anchor {
|
||||
diff_base_anchor: Some(start),
|
||||
..deleted_hunk_anchor
|
||||
}..Anchor {
|
||||
diff_base_anchor: Some(end),
|
||||
..deleted_hunk_anchor
|
||||
}
|
||||
deleted_hunk_anchor.with_diff_base_anchor(start)
|
||||
..deleted_hunk_anchor.with_diff_base_anchor(end)
|
||||
} else {
|
||||
let start = search_buffer
|
||||
.anchor_after(search_range.start + match_range.start);
|
||||
|
||||
Reference in New Issue
Block a user