editor: Shrink DisplayMapSnapshot from 824 to 256 bytes (#39568)

We have unnecessary clones for the fields here as most of the snapshots
contain the others hierarchically.

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-10-06 08:08:49 +00:00
committed by GitHub
parent 9c7369f54d
commit 2bfcd60b88
48 changed files with 594 additions and 543 deletions
+123 -114
View File
@@ -2297,7 +2297,7 @@ impl Editor {
let snapshot = editor.snapshot(window, cx);
editor.update_restoration_data(cx, move |data| {
data.scroll_position = (
new_anchor.top_row(&snapshot.buffer_snapshot),
new_anchor.top_row(snapshot.buffer_snapshot()),
new_anchor.offset,
);
});
@@ -3083,7 +3083,7 @@ impl Editor {
let display_map = self
.display_map
.update(cx, |display_map, cx| display_map.snapshot(cx));
let buffer = &display_map.buffer_snapshot;
let buffer = display_map.buffer_snapshot();
if self.selections.count() == 1 {
self.add_selections_state = None;
}
@@ -3247,22 +3247,23 @@ impl Editor {
return;
}
let Some(singleton) = self.buffer().read(cx).as_singleton() else {
if !self.buffer().read(cx).is_singleton() {
return;
}
let display_snapshot = self
.display_map
.update(cx, |display_map, cx| display_map.snapshot(cx));
let Some((.., snapshot)) = display_snapshot.buffer_snapshot().as_singleton() else {
return;
};
let snapshot = singleton.read(cx).snapshot();
let inmemory_folds = self.display_map.update(cx, |display_map, cx| {
let display_snapshot = display_map.snapshot(cx);
display_snapshot
.folds_in_range(0..display_snapshot.buffer_snapshot.len())
.map(|fold| {
fold.range.start.text_anchor.to_point(&snapshot)
..fold.range.end.text_anchor.to_point(&snapshot)
})
.collect()
});
let inmemory_folds = display_snapshot
.folds_in_range(0..display_snapshot.buffer_snapshot().len())
.map(|fold| {
fold.range.start.text_anchor.to_point(&snapshot)
..fold.range.end.text_anchor.to_point(&snapshot)
})
.collect();
self.update_restoration_data(cx, |data| {
data.folds = inmemory_folds;
});
@@ -3272,18 +3273,15 @@ impl Editor {
};
let background_executor = cx.background_executor().clone();
let editor_id = cx.entity().entity_id().as_u64() as ItemId;
let db_folds = self.display_map.update(cx, |display_map, cx| {
display_map
.snapshot(cx)
.folds_in_range(0..snapshot.len())
.map(|fold| {
(
fold.range.start.text_anchor.to_offset(&snapshot),
fold.range.end.text_anchor.to_offset(&snapshot),
)
})
.collect()
});
let db_folds = display_snapshot
.folds_in_range(0..display_snapshot.buffer_snapshot().len())
.map(|fold| {
(
fold.range.start.text_anchor.to_offset(&snapshot),
fold.range.end.text_anchor.to_offset(&snapshot),
)
})
.collect();
self.serialize_folds = cx.background_spawn(async move {
background_executor.timer(SERIALIZATION_THROTTLE_TIME).await;
DB.save_editor_folds(editor_id, workspace_id, db_folds)
@@ -3516,7 +3514,7 @@ impl Editor {
self.begin_selection(position, false, click_count, window, cx);
let position = position.to_offset(&display_map, Bias::Left);
let tail_anchor = display_map.buffer_snapshot.anchor_before(tail);
let tail_anchor = display_map.buffer_snapshot().anchor_before(tail);
let mut pending_selection = self
.selections
@@ -3561,7 +3559,7 @@ impl Editor {
}
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
let buffer = &display_map.buffer_snapshot;
let buffer = display_map.buffer_snapshot();
let position = display_map.clip_point(position, Bias::Left);
let start;
@@ -3669,7 +3667,7 @@ impl Editor {
if reset {
let pointer_position = display_map
.buffer_snapshot
.buffer_snapshot()
.anchor_before(position.to_point(&display_map));
self.change_selections(
@@ -3687,7 +3685,7 @@ impl Editor {
};
let tail = self.selections.newest::<Point>(cx).tail();
let selection_anchor = display_map.buffer_snapshot.anchor_before(tail);
let selection_anchor = display_map.buffer_snapshot().anchor_before(tail);
self.columnar_selection_state = match mode {
ColumnarMode::FromMouse => Some(ColumnarSelectionState::FromMouse {
selection_tail: selection_anchor,
@@ -3724,7 +3722,7 @@ impl Editor {
if self.columnar_selection_state.is_some() {
self.select_columns(position, goal_column, &display_map, window, cx);
} else if let Some(mut pending) = self.selections.pending_anchor().cloned() {
let buffer = &display_map.buffer_snapshot;
let buffer = display_map.buffer_snapshot();
let head;
let tail;
let mode = self.selections.pending_mode().unwrap();
@@ -3760,7 +3758,7 @@ impl Editor {
}
}
SelectMode::Line(original_range) => {
let original_range = original_range.to_point(&display_map.buffer_snapshot);
let original_range = original_range.to_point(display_map.buffer_snapshot());
let position = display_map
.clip_point(position, Bias::Left)
@@ -4339,15 +4337,19 @@ impl Editor {
let mut i = 0;
for (position, delta, selection_id, pair) in new_autoclose_regions {
let position = position.to_offset(&map.buffer_snapshot) + delta;
let start = map.buffer_snapshot.anchor_before(position);
let end = map.buffer_snapshot.anchor_after(position);
let position = position.to_offset(map.buffer_snapshot()) + delta;
let start = map.buffer_snapshot().anchor_before(position);
let end = map.buffer_snapshot().anchor_after(position);
while let Some(existing_state) = this.autoclose_regions.get(i) {
match existing_state.range.start.cmp(&start, &map.buffer_snapshot) {
match existing_state
.range
.start
.cmp(&start, map.buffer_snapshot())
{
Ordering::Less => i += 1,
Ordering::Greater => break,
Ordering::Equal => {
match end.cmp(&existing_state.range.end, &map.buffer_snapshot) {
match end.cmp(&existing_state.range.end, map.buffer_snapshot()) {
Ordering::Less => i += 1,
Ordering::Equal => break,
Ordering::Greater => break,
@@ -6158,7 +6160,7 @@ impl Editor {
_ => self.selections.newest::<Point>(cx).head(),
};
let Some((buffer, buffer_row)) = snapshot
.buffer_snapshot
.buffer_snapshot()
.buffer_line_for_row(MultiBufferRow(multibuffer_point.row))
.and_then(|(buffer_snapshot, range)| {
self.buffer()
@@ -6206,7 +6208,7 @@ impl Editor {
.zip(task_context.clone())
.map(|(tasks, task_context)| ResolvedTasks {
templates: tasks.resolve(&task_context).collect(),
position: snapshot.buffer_snapshot.anchor_before(Point::new(
position: snapshot.buffer_snapshot().anchor_before(Point::new(
multibuffer_point.row,
tasks.column,
)),
@@ -6688,7 +6690,7 @@ impl Editor {
pub fn blame_hover(&mut self, _: &BlameHover, window: &mut Window, cx: &mut Context<Self>) {
let snapshot = self.snapshot(window, cx);
let cursor = self.selections.newest::<Point>(cx).head();
let Some((buffer, point, _)) = snapshot.buffer_snapshot.point_to_buffer_point(cursor)
let Some((buffer, point, _)) = snapshot.buffer_snapshot().point_to_buffer_point(cursor)
else {
return;
};
@@ -7009,7 +7011,7 @@ impl Editor {
return;
}
let snapshot = self.snapshot(window, cx);
if snapshot.buffer_snapshot.max_point().row == 0 {
if snapshot.buffer_snapshot().max_point().row == 0 {
return;
}
let task = cx.background_spawn(async move {
@@ -7018,8 +7020,8 @@ impl Editor {
.filter_map(|(c, i)| {
if c == '\n' {
Some(
snapshot.buffer_snapshot.anchor_after(i)
..snapshot.buffer_snapshot.anchor_before(i + 1),
snapshot.buffer_snapshot().anchor_after(i)
..snapshot.buffer_snapshot().anchor_before(i + 1),
)
} else {
None
@@ -7027,7 +7029,7 @@ impl Editor {
})
.collect::<Vec<_>>();
let existing_newlines = snapshot
.folds_in_range(0..snapshot.buffer_snapshot.len())
.folds_in_range(0..snapshot.buffer_snapshot().len())
.filter_map(|fold| {
if fold.placeholder.type_tag == Some(type_id) {
Some(fold.range.start..fold.range.end)
@@ -8109,7 +8111,7 @@ impl Editor {
let snapshot = self.snapshot(window, cx);
let multi_buffer_snapshot = &snapshot.display_snapshot.buffer_snapshot;
let multi_buffer_snapshot = snapshot.display_snapshot.buffer_snapshot();
let Some(project) = self.project() else {
return breakpoint_display_points;
};
@@ -10011,7 +10013,7 @@ impl Editor {
movement::left(&display_map, old_head.to_display_point(&display_map))
.to_point(&display_map);
if let Some((buffer, line_buffer_range)) = display_map
.buffer_snapshot
.buffer_snapshot()
.buffer_line_for_row(MultiBufferRow(old_head.row))
{
let indent_size = buffer.indent_size_for_line(line_buffer_range.start.row);
@@ -10456,7 +10458,7 @@ impl Editor {
}
}
let buffer = &display_map.buffer_snapshot;
let buffer = display_map.buffer_snapshot();
let mut edit_start = Point::new(rows.start.0, 0).to_offset(buffer);
let edit_end = if buffer.max_point().row >= rows.end.0 {
// If there's a line after the range, delete the \n from the end of the row range
@@ -10891,7 +10893,7 @@ impl Editor {
cx: &mut Context<Self>,
) -> Option<(Anchor, Breakpoint)> {
let snapshot = self.snapshot(window, cx);
let breakpoint_position = snapshot.buffer_snapshot.anchor_before(Point::new(row, 0));
let breakpoint_position = snapshot.buffer_snapshot().anchor_before(Point::new(row, 0));
self.breakpoint_at_anchor(breakpoint_position, &snapshot, cx)
}
@@ -10914,9 +10916,9 @@ impl Editor {
.summary_for_anchor::<text::PointUtf16>(&breakpoint_position.text_anchor)
.row;
let line_len = snapshot.buffer_snapshot.line_len(MultiBufferRow(row));
let line_len = snapshot.buffer_snapshot().line_len(MultiBufferRow(row));
let anchor_end = snapshot
.buffer_snapshot
.buffer_snapshot()
.anchor_after(Point::new(row, line_len));
self.breakpoint_store
@@ -10937,7 +10939,7 @@ impl Editor {
if breakpoint_row == row {
snapshot
.buffer_snapshot
.buffer_snapshot()
.anchor_in_excerpt(enclosing_excerpt, bp.position)
.map(|position| (position, bp.bp.clone()))
} else {
@@ -10982,7 +10984,7 @@ impl Editor {
.disjoint_anchors_arc()
.iter()
.map(|selection| {
let cursor_position: Point = selection.head().to_point(&snapshot.buffer_snapshot);
let cursor_position: Point = selection.head().to_point(&snapshot.buffer_snapshot());
let breakpoint_position = self
.breakpoint_at_row(cursor_position.row, window, cx)
@@ -10990,7 +10992,7 @@ impl Editor {
.unwrap_or_else(|| {
snapshot
.display_snapshot
.buffer_snapshot
.buffer_snapshot()
.anchor_after(Point::new(cursor_position.row, 0))
});
@@ -11619,7 +11621,7 @@ impl Editor {
cx: &mut Context<Self>,
) {
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
let buffer = &display_map.buffer_snapshot;
let buffer = display_map.buffer_snapshot();
let mut edits = Vec::new();
let insert_point = display_map
.clip_point(target, Bias::Left)
@@ -11658,7 +11660,7 @@ impl Editor {
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
let buffer = &display_map.buffer_snapshot;
let buffer = display_map.buffer_snapshot();
let selections = self.selections.all::<Point>(cx);
let mut edits = Vec::new();
@@ -11960,7 +11962,7 @@ impl Editor {
let mut transpose_offset = head.to_offset(display_map, Bias::Right);
if head.column() == display_map.line_len(head.row()) {
transpose_offset = display_map
.buffer_snapshot
.buffer_snapshot()
.clip_offset(transpose_offset.saturating_sub(1), Bias::Left);
}
@@ -11978,14 +11980,16 @@ impl Editor {
selection.collapse_to(head, goal);
let transpose_start = display_map
.buffer_snapshot
.buffer_snapshot()
.clip_offset(transpose_offset.saturating_sub(1), Bias::Left);
if edits.last().is_none_or(|e| e.0.end <= transpose_start) {
let transpose_end = display_map
.buffer_snapshot
.buffer_snapshot()
.clip_offset(transpose_offset + 1, Bias::Right);
if let Some(ch) =
display_map.buffer_snapshot.chars_at(transpose_start).next()
if let Some(ch) = display_map
.buffer_snapshot()
.chars_at(transpose_start)
.next()
{
edits.push((transpose_start..transpose_offset, String::new()));
edits.push((transpose_end..transpose_end, ch.to_string()));
@@ -14093,7 +14097,7 @@ impl Editor {
self.hide_mouse_cursor(HideMouseCursorOrigin::MovementAction, cx);
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
let mut selections = self.selections.all::<Point>(cx);
let max_point = display_map.buffer_snapshot.max_point();
let max_point = display_map.buffer_snapshot().max_point();
for selection in &mut selections {
let rows = selection.spanned_rows(true, &display_map);
selection.start = Point::new(rows.start.0, 0);
@@ -14370,7 +14374,7 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) -> Result<()> {
let buffer = &display_map.buffer_snapshot;
let buffer = display_map.buffer_snapshot();
let mut selections = self.selections.all::<usize>(cx);
if let Some(mut select_next_state) = self.select_next_state.take() {
let query = &select_next_state.query;
@@ -14533,7 +14537,7 @@ impl Editor {
let mut new_selections = Vec::new();
let reversed = self.selections.oldest::<usize>(cx).reversed;
let buffer = &display_map.buffer_snapshot;
let buffer = display_map.buffer_snapshot();
let query_matches = select_next_state
.query
.stream_find_iter(buffer.bytes_in_range(0..buffer.len()));
@@ -14595,7 +14599,7 @@ impl Editor {
) -> Result<()> {
self.hide_mouse_cursor(HideMouseCursorOrigin::MovementAction, cx);
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
let buffer = &display_map.buffer_snapshot;
let buffer = display_map.buffer_snapshot();
let mut selections = self.selections.all::<usize>(cx);
if let Some(mut select_prev_state) = self.select_prev_state.take() {
let query = &select_prev_state.query;
@@ -15513,11 +15517,11 @@ impl Editor {
.fold(HashMap::default(), |mut acc, (kind, location, task)| {
let buffer = location.target.buffer;
let buffer_snapshot = buffer.read(cx).snapshot();
let offset = display_snapshot.buffer_snapshot.excerpts().find_map(
let offset = display_snapshot.buffer_snapshot().excerpts().find_map(
|(excerpt_id, snapshot, _)| {
if snapshot.remote_id() == buffer_snapshot.remote_id() {
display_snapshot
.buffer_snapshot
.buffer_snapshot()
.anchor_in_excerpt(excerpt_id, location.target.range.start)
} else {
None
@@ -15585,7 +15589,7 @@ impl Editor {
snapshot: &DisplaySnapshot,
range: Range<Anchor>,
) -> Vec<language::RunnableRange> {
snapshot.buffer_snapshot.runnable_ranges(range).collect()
snapshot.buffer_snapshot().runnable_ranges(range).collect()
}
fn runnable_rows(
@@ -15615,9 +15619,12 @@ impl Editor {
continue;
}
let point = runnable.run_range.start.to_point(&snapshot.buffer_snapshot);
let point = runnable
.run_range
.start
.to_point(&snapshot.buffer_snapshot());
let Some(row) = snapshot
.buffer_snapshot
.buffer_snapshot()
.buffer_line_for_row(MultiBufferRow(point.row))
.map(|(_, range)| range.start.row)
else {
@@ -15631,7 +15638,7 @@ impl Editor {
RunnableTasks {
templates: tasks,
offset: snapshot
.buffer_snapshot
.buffer_snapshot()
.anchor_before(runnable.run_range.start),
context_range,
column: point.column,
@@ -16088,12 +16095,12 @@ impl Editor {
position: Point,
) -> Option<MultiBufferDiffHunk> {
snapshot
.buffer_snapshot
.diff_hunks_in_range(position..snapshot.buffer_snapshot.max_point())
.buffer_snapshot()
.diff_hunks_in_range(position..snapshot.buffer_snapshot().max_point())
.find(|hunk| hunk.row_range.start.0 > position.row)
.or_else(|| {
snapshot
.buffer_snapshot
.buffer_snapshot()
.diff_hunks_in_range(Point::zero()..position)
.find(|hunk| hunk.row_range.end.0 < position.row)
})
@@ -16123,9 +16130,9 @@ impl Editor {
position: Point,
) -> Option<MultiBufferRow> {
snapshot
.buffer_snapshot
.buffer_snapshot()
.diff_hunk_before(position)
.or_else(|| snapshot.buffer_snapshot.diff_hunk_before(Point::MAX))
.or_else(|| snapshot.buffer_snapshot().diff_hunk_before(Point::MAX))
}
fn go_to_next_change(
@@ -16196,7 +16203,7 @@ impl Editor {
) {
self.hide_mouse_cursor(HideMouseCursorOrigin::MovementAction, cx);
let snapshot = self.snapshot(window, cx);
let buffer = &snapshot.buffer_snapshot;
let buffer = &snapshot.buffer_snapshot();
let position = self.selections.newest::<Point>(cx).head();
let anchor_position = buffer.anchor_after(position);
@@ -16259,13 +16266,13 @@ impl Editor {
cx: &mut Context<Self>,
) {
let snapshot = self.snapshot(window, cx).display_snapshot;
let position = position.to_point(&snapshot.buffer_snapshot);
let position = position.to_point(&snapshot.buffer_snapshot());
let start = snapshot
.buffer_snapshot
.buffer_snapshot()
.clip_point(Point::new(position.row, 0), Bias::Left);
let end = start + Point::new(1, 0);
let start = snapshot.buffer_snapshot.anchor_before(start);
let end = snapshot.buffer_snapshot.anchor_before(end);
let start = snapshot.buffer_snapshot().anchor_before(start);
let end = snapshot.buffer_snapshot().anchor_before(end);
self.highlight_rows::<T>(
start..end,
@@ -18078,7 +18085,7 @@ impl Editor {
if self.buffer.read(cx).is_singleton() {
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
let has_folds = display_map
.folds_in_range(0..display_map.buffer_snapshot.len())
.folds_in_range(0..display_map.buffer_snapshot().len())
.next()
.is_some();
@@ -18275,7 +18282,7 @@ impl Editor {
pub fn unfold_lines(&mut self, _: &UnfoldLines, _window: &mut Window, cx: &mut Context<Self>) {
if self.buffer_kind(cx) == ItemBufferKind::Singleton {
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
let buffer = &display_map.buffer_snapshot;
let buffer = display_map.buffer_snapshot();
let selections = self.selections.all::<Point>(cx);
let ranges = selections
.iter()
@@ -18337,7 +18344,7 @@ impl Editor {
let intersection_range = Point::new(buffer_row.0, 0)
..Point::new(
buffer_row.0,
display_map.buffer_snapshot.line_len(buffer_row),
display_map.buffer_snapshot().line_len(buffer_row),
);
let autoscroll = self
@@ -18357,7 +18364,7 @@ impl Editor {
) {
if self.buffer.read(cx).is_singleton() {
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
self.unfold_ranges(&[0..display_map.buffer_snapshot.len()], true, true, cx);
self.unfold_ranges(&[0..display_map.buffer_snapshot().len()], true, true, cx);
} else {
self.toggle_fold_multiple_buffers = cx.spawn(async move |editor, cx| {
editor
@@ -18713,8 +18720,8 @@ impl Editor {
let snapshot = self.snapshot(window, cx);
let position = self.selections.newest::<Point>(cx).head();
let mut row = snapshot
.buffer_snapshot
.diff_hunks_in_range(position..snapshot.buffer_snapshot.max_point())
.buffer_snapshot()
.diff_hunks_in_range(position..snapshot.buffer_snapshot().max_point())
.find(|hunk| hunk.row_range.start.0 > position.row)
.map(|hunk| hunk.row_range.start);
@@ -18723,7 +18730,7 @@ impl Editor {
if !all_diff_hunks_expanded {
row = row.or_else(|| {
snapshot
.buffer_snapshot
.buffer_snapshot()
.diff_hunks_in_range(Point::zero()..position)
.find(|hunk| hunk.row_range.end.0 < position.row)
.map(|hunk| hunk.row_range.start)
@@ -19596,7 +19603,7 @@ impl Editor {
let blame = self.blame.as_ref()?;
let snapshot = self.snapshot(window, cx);
let cursor = self.selections.newest::<Point>(cx).head();
let (buffer, point, _) = snapshot.buffer_snapshot.point_to_buffer_point(cursor)?;
let (buffer, point, _) = snapshot.buffer_snapshot().point_to_buffer_point(cursor)?;
let (_, blame_entry) = blame
.update(cx, |blame, cx| {
blame
@@ -20307,7 +20314,7 @@ impl Editor {
cx: &mut Context<Self>,
) -> Vec<(Range<DisplayPoint>, Hsla)> {
let snapshot = self.snapshot(window, cx);
let buffer = &snapshot.buffer_snapshot;
let buffer = &snapshot.buffer_snapshot();
let start = buffer.anchor_before(0);
let end = buffer.anchor_after(buffer.len());
self.sorted_background_highlights_in_range(start..end, &snapshot, cx.theme())
@@ -20407,7 +20414,7 @@ impl Editor {
let start_ix = match ranges.binary_search_by(|probe| {
let cmp = probe
.end
.cmp(&search_range.start, &display_snapshot.buffer_snapshot);
.cmp(&search_range.start, &display_snapshot.buffer_snapshot());
if cmp.is_gt() {
Ordering::Greater
} else {
@@ -20419,7 +20426,7 @@ impl Editor {
for range in &ranges[start_ix..] {
if range
.start
.cmp(&search_range.end, &display_snapshot.buffer_snapshot)
.cmp(&search_range.end, &display_snapshot.buffer_snapshot())
.is_ge()
{
break;
@@ -20445,7 +20452,7 @@ impl Editor {
let start_ix = match ranges.binary_search_by(|probe| {
let cmp = probe
.end
.cmp(&search_range.start, &display_snapshot.buffer_snapshot);
.cmp(&search_range.start, &display_snapshot.buffer_snapshot());
if cmp.is_gt() {
Ordering::Greater
} else {
@@ -20457,7 +20464,7 @@ impl Editor {
for range in &ranges[start_ix..] {
if range
.start
.cmp(&search_range.end, &display_snapshot.buffer_snapshot)
.cmp(&search_range.end, &display_snapshot.buffer_snapshot())
.is_ge()
{
break;
@@ -20479,7 +20486,7 @@ impl Editor {
cx: &App,
) -> Vec<Range<DisplayPoint>> {
display_snapshot
.buffer_snapshot
.buffer_snapshot()
.redacted_ranges(search_range, |file| {
if let Some(file) = file {
file.is_private()
@@ -21597,9 +21604,9 @@ impl Editor {
.all::<usize>(cx)
.into_iter()
.map(|selection| {
snapshot.buffer_snapshot.anchor_after(selection.end)
snapshot.buffer_snapshot().anchor_after(selection.end)
..snapshot
.buffer_snapshot
.buffer_snapshot()
.anchor_before(selection.end + pending.len())
})
.collect();
@@ -23218,7 +23225,7 @@ impl EditorSnapshot {
.values()
.map(|collaborator| (collaborator.replica_id, collaborator))
.collect::<HashMap<_, _>>();
self.buffer_snapshot
self.buffer_snapshot()
.selections_in_range(range, false)
.filter_map(move |(replica_id, line_mode, cursor_shape, selection)| {
if replica_id == AGENT_REPLICA_ID {
@@ -23262,7 +23269,7 @@ impl EditorSnapshot {
for query_range in ranges {
let query_rows =
MultiBufferRow(query_range.start.row)..MultiBufferRow(query_range.end.row + 1);
for hunk in self.buffer_snapshot.diff_hunks_in_range(
for hunk in self.buffer_snapshot().diff_hunks_in_range(
Point::new(query_rows.start.0, 0)..Point::new(query_rows.end.0, 0),
) {
// Include deleted hunks that are adjacent to the query range, because
@@ -23296,7 +23303,7 @@ impl EditorSnapshot {
let buffer_start = DisplayPoint::new(display_rows.start, 0).to_point(self);
let buffer_end = DisplayPoint::new(display_rows.end, 0).to_point(self);
self.buffer_snapshot
self.buffer_snapshot()
.diff_hunks_in_range(buffer_start..buffer_end)
.filter_map(|hunk| {
if folded_buffers.contains(&hunk.buffer_id) {
@@ -23337,7 +23344,9 @@ impl EditorSnapshot {
}
pub fn language_at<T: ToOffset>(&self, position: T) -> Option<&Arc<Language>> {
self.display_snapshot.buffer_snapshot.language_at(position)
self.display_snapshot
.buffer_snapshot()
.language_at(position)
}
pub fn is_focused(&self) -> bool {
@@ -23408,7 +23417,7 @@ impl EditorSnapshot {
ch_advance * max_char_count
});
let is_singleton = self.buffer_snapshot.is_singleton();
let is_singleton = self.buffer_snapshot().is_singleton();
let mut left_padding = git_blame_entries_width.unwrap_or(Pixels::ZERO);
left_padding += if !is_singleton {
@@ -23457,7 +23466,7 @@ impl EditorSnapshot {
if let Some(crease) = self
.crease_snapshot
.query_row(buffer_row, &self.buffer_snapshot)
.query_row(buffer_row, self.buffer_snapshot())
{
is_foldable = true;
match crease {
@@ -23516,7 +23525,7 @@ impl EditorSnapshot {
let folded = self.is_line_folded(buffer_row);
if let Crease::Inline { render_trailer, .. } = self
.crease_snapshot
.query_row(buffer_row, &self.buffer_snapshot)?
.query_row(buffer_row, self.buffer_snapshot())?
{
let render_trailer = render_trailer.as_ref()?;
Some(render_trailer(buffer_row, folded, window, cx))
@@ -23947,7 +23956,7 @@ impl EntityInputHandler for Editor {
let anchor = position_map
.snapshot
.display_point_to_anchor(display_point, Bias::Left);
let utf16_offset = anchor.to_offset_utf16(&position_map.snapshot.buffer_snapshot);
let utf16_offset = anchor.to_offset_utf16(&position_map.snapshot.buffer_snapshot());
Some(utf16_offset.0)
}
}
@@ -23965,11 +23974,11 @@ impl<T: ToPoint + ToOffset> SelectionExt for Selection<T> {
fn display_range(&self, map: &DisplaySnapshot) -> Range<DisplayPoint> {
let start = self
.start
.to_point(&map.buffer_snapshot)
.to_point(map.buffer_snapshot())
.to_display_point(map);
let end = self
.end
.to_point(&map.buffer_snapshot)
.to_point(map.buffer_snapshot())
.to_display_point(map);
if self.reversed {
end..start
@@ -23983,8 +23992,8 @@ impl<T: ToPoint + ToOffset> SelectionExt for Selection<T> {
include_end_if_at_line_start: bool,
map: &DisplaySnapshot,
) -> Range<MultiBufferRow> {
let start = self.start.to_point(&map.buffer_snapshot);
let mut end = self.end.to_point(&map.buffer_snapshot);
let start = self.start.to_point(map.buffer_snapshot());
let mut end = self.end.to_point(map.buffer_snapshot());
if !include_end_if_at_line_start && start.row != end.row && end.column == 0 {
end.row -= 1;
}
@@ -24174,7 +24183,7 @@ pub trait RangeToAnchorExt: Sized {
fn to_anchors(self, snapshot: &MultiBufferSnapshot) -> Range<Anchor>;
fn to_display_points(self, snapshot: &EditorSnapshot) -> Range<DisplayPoint> {
let anchor_range = self.to_anchors(&snapshot.buffer_snapshot);
let anchor_range = self.to_anchors(&snapshot.buffer_snapshot());
anchor_range.start.to_display_point(snapshot)..anchor_range.end.to_display_point(snapshot)
}
}
@@ -24635,7 +24644,7 @@ fn render_diff_hunk_controls(
move |_event, window, cx| {
editor.update(cx, |editor, cx| {
let snapshot = editor.snapshot(window, cx);
let point = hunk_range.start.to_point(&snapshot.buffer_snapshot);
let point = hunk_range.start.to_point(&snapshot.buffer_snapshot());
editor.restore_hunks_in_ranges(vec![point..point], window, cx);
});
}
@@ -24668,7 +24677,7 @@ fn render_diff_hunk_controls(
editor.update(cx, |editor, cx| {
let snapshot = editor.snapshot(window, cx);
let position =
hunk_range.end.to_point(&snapshot.buffer_snapshot);
hunk_range.end.to_point(&snapshot.buffer_snapshot());
editor.go_to_hunk_before_or_after_position(
&snapshot,
position,
@@ -24704,7 +24713,7 @@ fn render_diff_hunk_controls(
editor.update(cx, |editor, cx| {
let snapshot = editor.snapshot(window, cx);
let point =
hunk_range.start.to_point(&snapshot.buffer_snapshot);
hunk_range.start.to_point(&snapshot.buffer_snapshot());
editor.go_to_hunk_before_or_after_position(
&snapshot,
point,