multi_buffer: Remove redundant buffer id field (#43459)
It is easy for us to get the two fields out of sync causing weird problems, there is no reason to have both here so. Release Notes: - N/A *or* Added/Fixed/Improved ... Co-authored by: Antonio Scandurra <antonio@zed.dev>
This commit is contained in:
+14
-21
@@ -1780,7 +1780,7 @@ impl Editor {
|
||||
let start_row = (multi_buffer_visible_start.row).min(max_row);
|
||||
let end_row = (multi_buffer_visible_start.row + 10).min(max_row);
|
||||
|
||||
if let Some((excerpt_id, buffer_id, buffer)) = multi_buffer.read(cx).as_singleton() {
|
||||
if let Some((excerpt_id, _, buffer)) = multi_buffer.read(cx).as_singleton() {
|
||||
let outline_items = buffer
|
||||
.outline_items_containing(
|
||||
Point::new(start_row, 0)..Point::new(end_row, 0),
|
||||
@@ -1790,10 +1790,9 @@ impl Editor {
|
||||
.into_iter()
|
||||
.map(|outline_item| OutlineItem {
|
||||
depth: outline_item.depth,
|
||||
range: Anchor::range_in_buffer(*excerpt_id, buffer_id, outline_item.range),
|
||||
range: Anchor::range_in_buffer(*excerpt_id, outline_item.range),
|
||||
source_range_for_text: Anchor::range_in_buffer(
|
||||
*excerpt_id,
|
||||
buffer_id,
|
||||
outline_item.source_range_for_text,
|
||||
),
|
||||
text: outline_item.text,
|
||||
@@ -1801,10 +1800,10 @@ impl Editor {
|
||||
name_ranges: outline_item.name_ranges,
|
||||
body_range: outline_item
|
||||
.body_range
|
||||
.map(|range| Anchor::range_in_buffer(*excerpt_id, buffer_id, range)),
|
||||
.map(|range| Anchor::range_in_buffer(*excerpt_id, range)),
|
||||
annotation_range: outline_item
|
||||
.annotation_range
|
||||
.map(|range| Anchor::range_in_buffer(*excerpt_id, buffer_id, range)),
|
||||
.map(|range| Anchor::range_in_buffer(*excerpt_id, range)),
|
||||
});
|
||||
return Some(outline_items.collect());
|
||||
}
|
||||
@@ -3259,7 +3258,7 @@ impl Editor {
|
||||
}
|
||||
|
||||
if local {
|
||||
if let Some(buffer_id) = new_cursor_position.buffer_id {
|
||||
if let Some(buffer_id) = new_cursor_position.text_anchor.buffer_id {
|
||||
self.register_buffer(buffer_id, cx);
|
||||
}
|
||||
|
||||
@@ -4198,8 +4197,8 @@ impl Editor {
|
||||
continue;
|
||||
}
|
||||
if self.selections.disjoint_anchor_ranges().any(|s| {
|
||||
if s.start.buffer_id != selection.start.buffer_id
|
||||
|| s.end.buffer_id != selection.end.buffer_id
|
||||
if s.start.text_anchor.buffer_id != selection.start.buffer_id
|
||||
|| s.end.text_anchor.buffer_id != selection.end.buffer_id
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -5484,6 +5483,7 @@ impl Editor {
|
||||
}
|
||||
let buffer_position = multibuffer_snapshot.anchor_before(position);
|
||||
let Some(buffer) = buffer_position
|
||||
.text_anchor
|
||||
.buffer_id
|
||||
.and_then(|buffer_id| self.buffer.read(cx).buffer(buffer_id))
|
||||
else {
|
||||
@@ -6923,8 +6923,7 @@ impl Editor {
|
||||
continue;
|
||||
}
|
||||
|
||||
let range =
|
||||
Anchor::range_in_buffer(excerpt_id, buffer_id, *start..*end);
|
||||
let range = Anchor::range_in_buffer(excerpt_id, *start..*end);
|
||||
if highlight.kind == lsp::DocumentHighlightKind::WRITE {
|
||||
write_ranges.push(range);
|
||||
} else {
|
||||
@@ -7033,11 +7032,8 @@ impl Editor {
|
||||
.anchor_after(search_range.start + match_range.start);
|
||||
let match_end = buffer_snapshot
|
||||
.anchor_before(search_range.start + match_range.end);
|
||||
let match_anchor_range = Anchor::range_in_buffer(
|
||||
excerpt_id,
|
||||
buffer_snapshot.remote_id(),
|
||||
match_start..match_end,
|
||||
);
|
||||
let match_anchor_range =
|
||||
Anchor::range_in_buffer(excerpt_id, match_start..match_end);
|
||||
(match_anchor_range != query_range).then_some(match_anchor_range)
|
||||
}),
|
||||
);
|
||||
@@ -8212,8 +8208,7 @@ impl Editor {
|
||||
cx,
|
||||
);
|
||||
for (breakpoint, state) in breakpoints {
|
||||
let multi_buffer_anchor =
|
||||
Anchor::in_buffer(excerpt_id, buffer_snapshot.remote_id(), breakpoint.position);
|
||||
let multi_buffer_anchor = Anchor::in_buffer(excerpt_id, breakpoint.position);
|
||||
let position = multi_buffer_anchor
|
||||
.to_point(&multi_buffer_snapshot)
|
||||
.to_display_point(&snapshot);
|
||||
@@ -20804,8 +20799,7 @@ impl Editor {
|
||||
let start = highlight.range.start.to_display_point(&snapshot);
|
||||
let end = highlight.range.end.to_display_point(&snapshot);
|
||||
let start_row = start.row().0;
|
||||
let end_row = if highlight.range.end.text_anchor != text::Anchor::MAX
|
||||
&& end.column() == 0
|
||||
let end_row = if !highlight.range.end.text_anchor.is_max() && end.column() == 0
|
||||
{
|
||||
end.row().0.saturating_sub(1)
|
||||
} else {
|
||||
@@ -21361,7 +21355,7 @@ impl Editor {
|
||||
.for_each(|hint| {
|
||||
let inlay = Inlay::debugger(
|
||||
post_inc(&mut editor.next_inlay_id),
|
||||
Anchor::in_buffer(excerpt_id, buffer_id, hint.position),
|
||||
Anchor::in_buffer(excerpt_id, hint.position),
|
||||
hint.text(),
|
||||
);
|
||||
if !inlay.text().chars().contains(&'\n') {
|
||||
@@ -24105,7 +24099,6 @@ impl EditorSnapshot {
|
||||
display_row_range: hunk_display_start.row()..end_row,
|
||||
multi_buffer_range: Anchor::range_in_buffer(
|
||||
hunk.excerpt_id,
|
||||
hunk.buffer_id,
|
||||
hunk.buffer_range,
|
||||
),
|
||||
is_created_file,
|
||||
|
||||
Reference in New Issue
Block a user