multi_buffer: Fix up some anchor checks (#43454)

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-11-25 13:41:19 +00:00
committed by GitHub
parent a359a5a1f2
commit f8965317c3
15 changed files with 154 additions and 58 deletions
+9 -4
View File
@@ -57,7 +57,7 @@ impl MultiBuffer {
let snapshot = self.read(cx);
let excerpt = snapshot.excerpt(*excerpt_id)?;
Some(Anchor::in_buffer(
*excerpt_id,
excerpt.id,
excerpt.buffer_id,
excerpt.range.context.start,
))
@@ -182,11 +182,16 @@ impl MultiBuffer {
};
let ids_to_expand = HashSet::from_iter(ids);
let mut excerpt_id_ = None;
let expanded_ranges = excerpt_ids.iter().filter_map(|excerpt_id| {
let excerpt = snapshot.excerpt(*excerpt_id)?;
let excerpt_id = excerpt.id;
if excerpt_id_.is_none() {
excerpt_id_ = Some(excerpt_id);
}
let mut context = excerpt.range.context.to_point(&excerpt.buffer);
if ids_to_expand.contains(excerpt_id) {
if ids_to_expand.contains(&excerpt_id) {
match direction {
ExpandExcerptDirection::Up => {
context.start.row = context.start.row.saturating_sub(line_count);
@@ -222,10 +227,10 @@ impl MultiBuffer {
}
merged_ranges.push(range)
}
let Some(excerpt_id) = excerpt_ids.first() else {
let Some(excerpt_id) = excerpt_id_ else {
continue;
};
let Some(buffer_id) = &snapshot.buffer_id_for_excerpt(*excerpt_id) else {
let Some(buffer_id) = &snapshot.buffer_id_for_excerpt(excerpt_id) else {
continue;
};