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
+10 -10
View File
@@ -602,7 +602,7 @@ pub fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
let buffer_row = action.range.head().buffer_row(vim, editor, window, cx)?;
let current = editor.selections.newest::<Point>(cx);
let target = snapshot
.buffer_snapshot
.buffer_snapshot()
.clip_point(Point::new(buffer_row.0, current.head().column), Bias::Left);
editor.change_selections(Default::default(), window, cx, |s| {
s.select_ranges([target..target]);
@@ -624,10 +624,10 @@ pub fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
vim.update_editor(cx, |vim, editor, cx| {
let snapshot = editor.snapshot(window, cx);
if let Ok(range) = action.range.buffer_range(vim, editor, window, cx) {
let end = if range.end < snapshot.buffer_snapshot.max_row() {
let end = if range.end < snapshot.buffer_snapshot().max_row() {
Point::new(range.end.0 + 1, 0)
} else {
snapshot.buffer_snapshot.max_point()
snapshot.buffer_snapshot().max_point()
};
vim.copy_ranges(
editor,
@@ -963,7 +963,7 @@ impl Position {
)
}) {
anchor
.to_point(&snapshot.buffer_snapshot)
.to_point(&snapshot.buffer_snapshot())
.row
.saturating_add_signed(*offset)
} else {
@@ -979,12 +979,12 @@ impl Position {
let Some(mark) = anchors.last() else {
anyhow::bail!("mark {name} contains empty anchors");
};
mark.to_point(&snapshot.buffer_snapshot)
mark.to_point(&snapshot.buffer_snapshot())
.row
.saturating_add_signed(*offset)
}
Position::LastLine { offset } => snapshot
.buffer_snapshot
.buffer_snapshot()
.max_row()
.0
.saturating_add_signed(*offset),
@@ -992,12 +992,12 @@ impl Position {
.selections
.newest_anchor()
.head()
.to_point(&snapshot.buffer_snapshot)
.to_point(&snapshot.buffer_snapshot())
.row
.saturating_add_signed(*offset),
};
Ok(MultiBufferRow(target).min(snapshot.buffer_snapshot.max_row()))
Ok(MultiBufferRow(target).min(snapshot.buffer_snapshot().max_row()))
}
}
@@ -1652,7 +1652,7 @@ impl OnMatchingLines {
let point_range = Point::new(range.start.0, 0)
..snapshot
.buffer_snapshot
.buffer_snapshot()
.clip_point(Point::new(range.end.0 + 1, 0), Bias::Left);
cx.spawn_in(window, async move |editor, cx| {
let new_selections = cx
@@ -1660,7 +1660,7 @@ impl OnMatchingLines {
let mut line = String::new();
let mut new_selections = Vec::new();
let chunks = snapshot
.buffer_snapshot
.buffer_snapshot()
.text_for_range(point_range)
.chain(["\n"]);
+5 -5
View File
@@ -133,7 +133,7 @@ impl Vim {
self.helix_new_selections(window, cx, |cursor, map| {
let mut head = movement::right(map, cursor);
let mut tail = cursor;
let classifier = map.buffer_snapshot.char_classifier_at(head.to_point(map));
let classifier = map.buffer_snapshot().char_classifier_at(head.to_point(map));
if head == map.max_point() {
return None;
}
@@ -170,7 +170,7 @@ impl Vim {
// but the search starts from the left side of it,
// so to include that space the selection must end one character to the right.
let mut tail = movement::right(map, cursor);
let classifier = map.buffer_snapshot.char_classifier_at(head.to_point(map));
let classifier = map.buffer_snapshot().char_classifier_at(head.to_point(map));
if head == DisplayPoint::zero() {
return None;
}
@@ -467,7 +467,7 @@ impl Vim {
let was_empty = range.is_empty();
let was_reversed = selection.reversed;
(
map.buffer_snapshot.anchor_before(start_offset),
map.buffer_snapshot().anchor_before(start_offset),
end_offset - start_offset,
was_empty,
was_reversed,
@@ -546,8 +546,8 @@ impl Vim {
editor.hide_mouse_cursor(HideMouseCursorOrigin::MovementAction, cx);
let display_map = editor.display_map.update(cx, |map, cx| map.snapshot(cx));
let mut selections = editor.selections.all::<Point>(cx);
let max_point = display_map.buffer_snapshot.max_point();
let buffer_snapshot = &display_map.buffer_snapshot;
let max_point = display_map.buffer_snapshot().max_point();
let buffer_snapshot = &display_map.buffer_snapshot();
for selection in &mut selections {
// Start always goes to column 0 of the first selected line
+13 -11
View File
@@ -166,14 +166,16 @@ impl DerefMut for Offset {
}
impl Offset {
fn next(self, map: &DisplaySnapshot) -> Option<Self> {
let next = Self(map.buffer_snapshot.clip_offset(*self + 1, Bias::Right));
let next = Self(map.buffer_snapshot().clip_offset(*self + 1, Bias::Right));
(*next > *self).then(|| next)
}
fn previous(self, map: &DisplaySnapshot) -> Option<Self> {
if *self == 0 {
return None;
}
Some(Self(map.buffer_snapshot.clip_offset(*self - 1, Bias::Left)))
Some(Self(
map.buffer_snapshot().clip_offset(*self - 1, Bias::Left),
))
}
fn range(
start: (DisplayPoint, Bias),
@@ -388,7 +390,7 @@ impl ImmediateBoundary {
impl BoundedObject for ImmediateBoundary {
fn next_start(&self, map: &DisplaySnapshot, from: Offset, outer: bool) -> Option<Offset> {
try_find_boundary(map, from, |left, right| {
let classifier = map.buffer_snapshot.char_classifier_at(*from);
let classifier = map.buffer_snapshot().char_classifier_at(*from);
if outer {
self.is_outer_start(left, right, classifier)
} else {
@@ -398,7 +400,7 @@ impl BoundedObject for ImmediateBoundary {
}
fn next_end(&self, map: &DisplaySnapshot, from: Offset, outer: bool) -> Option<Offset> {
try_find_boundary(map, from, |left, right| {
let classifier = map.buffer_snapshot.char_classifier_at(*from);
let classifier = map.buffer_snapshot().char_classifier_at(*from);
if outer {
self.is_outer_end(left, right, classifier)
} else {
@@ -408,7 +410,7 @@ impl BoundedObject for ImmediateBoundary {
}
fn previous_start(&self, map: &DisplaySnapshot, from: Offset, outer: bool) -> Option<Offset> {
try_find_preceding_boundary(map, from, |left, right| {
let classifier = map.buffer_snapshot.char_classifier_at(*from);
let classifier = map.buffer_snapshot().char_classifier_at(*from);
if outer {
self.is_outer_start(left, right, classifier)
} else {
@@ -418,7 +420,7 @@ impl BoundedObject for ImmediateBoundary {
}
fn previous_end(&self, map: &DisplaySnapshot, from: Offset, outer: bool) -> Option<Offset> {
try_find_preceding_boundary(map, from, |left, right| {
let classifier = map.buffer_snapshot.char_classifier_at(*from);
let classifier = map.buffer_snapshot().char_classifier_at(*from);
if outer {
self.is_outer_end(left, right, classifier)
} else {
@@ -570,7 +572,7 @@ impl FuzzyBoundary {
boundary_kind: Boundary,
) -> Option<Offset> {
let generate_boundary_data = |left, right, point: Offset| {
let classifier = map.buffer_snapshot.char_classifier_at(*from);
let classifier = map.buffer_snapshot().char_classifier_at(*from);
let reach_boundary = if outer && boundary_kind == Boundary::Start {
self.is_near_potential_outer_start(left, right, &classifier)
} else if !outer && boundary_kind == Boundary::Start {
@@ -659,12 +661,12 @@ fn try_find_boundary_data<T>(
boundary_information: impl Fn(char, char, Offset) -> Option<T>,
) -> Option<T> {
let mut prev_ch = map
.buffer_snapshot
.buffer_snapshot()
.reversed_chars_at(*from)
.next()
.unwrap_or('\0');
for ch in map.buffer_snapshot.chars_at(*from).chain(['\0']) {
for ch in map.buffer_snapshot().chars_at(*from).chain(['\0']) {
if let Some(boundary_information) = boundary_information(prev_ch, ch, from) {
return Some(boundary_information);
}
@@ -700,9 +702,9 @@ fn try_find_preceding_boundary_data<T>(
mut from: Offset,
is_boundary: impl Fn(char, char, Offset) -> Option<T>,
) -> Option<T> {
let mut prev_ch = map.buffer_snapshot.chars_at(*from).next().unwrap_or('\0');
let mut prev_ch = map.buffer_snapshot().chars_at(*from).next().unwrap_or('\0');
for ch in map.buffer_snapshot.reversed_chars_at(*from).chain(['\0']) {
for ch in map.buffer_snapshot().reversed_chars_at(*from).chain(['\0']) {
if let Some(boundary_information) = is_boundary(ch, prev_ch, from) {
return Some(boundary_information);
}
+2 -2
View File
@@ -109,9 +109,9 @@ impl Vim {
};
let point = display_point.to_point(&display_map);
let anchor = if action.before {
display_map.buffer_snapshot.anchor_after(point)
display_map.buffer_snapshot().anchor_after(point)
} else {
display_map.buffer_snapshot.anchor_before(point)
display_map.buffer_snapshot().anchor_before(point)
};
edits.push((point..point, to_insert.repeat(count)));
new_selections.push((anchor, to_insert.len() * count));
+63 -63
View File
@@ -1387,7 +1387,7 @@ impl Motion {
let end = selection.end.to_point(map);
let start_row = MultiBufferRow(selection.start.to_point(map).row);
if end.row > start.row {
selection.end = Point::new(start_row.0, map.buffer_snapshot.line_len(start_row))
selection.end = Point::new(start_row.0, map.buffer_snapshot().line_len(start_row))
.to_display_point(map);
// a bit of a hack, we need `cw` on a blank line to not delete the newline,
@@ -1537,11 +1537,11 @@ pub(crate) fn start_of_relative_buffer_row(
) -> DisplayPoint {
let start = map.display_point_to_fold_point(point, Bias::Left);
let target = start.row() as isize + times;
let new_row = (target.max(0) as u32).min(map.fold_snapshot.max_point().row());
let new_row = (target.max(0) as u32).min(map.fold_snapshot().max_point().row());
map.clip_point(
map.fold_point_to_display_point(
map.fold_snapshot
map.fold_snapshot()
.clip_point(FoldPoint::new(new_row, 0), Bias::Right),
),
Bias::Right,
@@ -1571,7 +1571,7 @@ fn up_down_buffer_rows(
let start = map.display_point_to_fold_point(point, Bias::Left);
let begin_folded_line = map.fold_point_to_display_point(
map.fold_snapshot
map.fold_snapshot()
.clip_point(FoldPoint::new(start.row(), 0), Bias::Left),
);
let select_nth_wrapped_row = point.row().0 - begin_folded_line.row().0;
@@ -1588,10 +1588,10 @@ fn up_down_buffer_rows(
};
let target = start.row() as isize + times;
let new_row = (target.max(0) as u32).min(map.fold_snapshot.max_point().row());
let new_row = (target.max(0) as u32).min(map.fold_snapshot().max_point().row());
let mut begin_folded_line = map.fold_point_to_display_point(
map.fold_snapshot
map.fold_snapshot()
.clip_point(FoldPoint::new(new_row, 0), bias),
);
@@ -1697,7 +1697,7 @@ pub(crate) fn next_word_start(
times: usize,
) -> DisplayPoint {
let classifier = map
.buffer_snapshot
.buffer_snapshot()
.char_classifier_at(point.to_point(map))
.ignore_punctuation(ignore_punctuation);
for _ in 0..times {
@@ -1731,7 +1731,7 @@ pub(crate) fn next_word_end(
always_advance: bool,
) -> DisplayPoint {
let classifier = map
.buffer_snapshot
.buffer_snapshot()
.char_classifier_at(point.to_point(map))
.ignore_punctuation(ignore_punctuation);
for _ in 0..times {
@@ -1779,7 +1779,7 @@ fn previous_word_start(
times: usize,
) -> DisplayPoint {
let classifier = map
.buffer_snapshot
.buffer_snapshot()
.char_classifier_at(point.to_point(map))
.ignore_punctuation(ignore_punctuation);
for _ in 0..times {
@@ -1811,19 +1811,19 @@ fn previous_word_end(
times: usize,
) -> DisplayPoint {
let classifier = map
.buffer_snapshot
.buffer_snapshot()
.char_classifier_at(point.to_point(map))
.ignore_punctuation(ignore_punctuation);
let mut point = point.to_point(map);
if point.column < map.buffer_snapshot.line_len(MultiBufferRow(point.row))
&& let Some(ch) = map.buffer_snapshot.chars_at(point).next()
if point.column < map.buffer_snapshot().line_len(MultiBufferRow(point.row))
&& let Some(ch) = map.buffer_snapshot().chars_at(point).next()
{
point.column += ch.len_utf8() as u32;
}
for _ in 0..times {
let new_point = movement::find_preceding_boundary_point(
&map.buffer_snapshot,
&map.buffer_snapshot(),
point,
FindRange::MultiLine,
|left, right| {
@@ -1854,7 +1854,7 @@ fn next_subword_start(
times: usize,
) -> DisplayPoint {
let classifier = map
.buffer_snapshot
.buffer_snapshot()
.char_classifier_at(point.to_point(map))
.ignore_punctuation(ignore_punctuation);
for _ in 0..times {
@@ -1891,7 +1891,7 @@ pub(crate) fn next_subword_end(
allow_cross_newline: bool,
) -> DisplayPoint {
let classifier = map
.buffer_snapshot
.buffer_snapshot()
.char_classifier_at(point.to_point(map))
.ignore_punctuation(ignore_punctuation);
for _ in 0..times {
@@ -1942,7 +1942,7 @@ fn previous_subword_start(
times: usize,
) -> DisplayPoint {
let classifier = map
.buffer_snapshot
.buffer_snapshot()
.char_classifier_at(point.to_point(map))
.ignore_punctuation(ignore_punctuation);
for _ in 0..times {
@@ -1986,19 +1986,19 @@ fn previous_subword_end(
times: usize,
) -> DisplayPoint {
let classifier = map
.buffer_snapshot
.buffer_snapshot()
.char_classifier_at(point.to_point(map))
.ignore_punctuation(ignore_punctuation);
let mut point = point.to_point(map);
if point.column < map.buffer_snapshot.line_len(MultiBufferRow(point.row))
&& let Some(ch) = map.buffer_snapshot.chars_at(point).next()
if point.column < map.buffer_snapshot().line_len(MultiBufferRow(point.row))
&& let Some(ch) = map.buffer_snapshot().chars_at(point).next()
{
point.column += ch.len_utf8() as u32;
}
for _ in 0..times {
let new_point = movement::find_preceding_boundary_point(
&map.buffer_snapshot,
&map.buffer_snapshot(),
point,
FindRange::MultiLine,
|left, right| {
@@ -2034,7 +2034,7 @@ pub(crate) fn first_non_whitespace(
from: DisplayPoint,
) -> DisplayPoint {
let mut start_offset = start_of_line(map, display_lines, from).to_offset(map, Bias::Left);
let classifier = map.buffer_snapshot.char_classifier_at(from.to_point(map));
let classifier = map.buffer_snapshot().char_classifier_at(from.to_point(map));
for (ch, offset) in map.buffer_chars_at(start_offset) {
if ch == '\n' {
return from;
@@ -2056,7 +2056,7 @@ pub(crate) fn last_non_whitespace(
count: usize,
) -> DisplayPoint {
let mut end_of_line = end_of_line(map, false, from, count).to_offset(map, Bias::Left);
let classifier = map.buffer_snapshot.char_classifier_at(from.to_point(map));
let classifier = map.buffer_snapshot().char_classifier_at(from.to_point(map));
// NOTE: depending on clip_at_line_end we may already be one char back from the end.
if let Some((ch, _)) = map.buffer_chars_at(end_of_line).next()
@@ -2112,7 +2112,7 @@ pub(crate) fn middle_of_line(
} else {
let mut buffer_point = point.to_point(map);
buffer_point.column = (map
.buffer_snapshot
.buffer_snapshot()
.line_len(MultiBufferRow(buffer_point.row)) as f64
* percent) as u32;
@@ -2144,7 +2144,7 @@ pub(crate) fn sentence_backwards(
point: DisplayPoint,
mut times: usize,
) -> DisplayPoint {
let mut start = point.to_point(map).to_offset(&map.buffer_snapshot);
let mut start = point.to_point(map).to_offset(&map.buffer_snapshot());
let mut chars = map.reverse_buffer_chars_at(start).peekable();
let mut was_newline = map
@@ -2170,7 +2170,7 @@ pub(crate) fn sentence_backwards(
if times == 0 || offset == 0 {
return map.clip_point(
start_of_next_sentence
.to_offset(&map.buffer_snapshot)
.to_offset(&map.buffer_snapshot())
.to_display_point(map),
Bias::Left,
);
@@ -2190,7 +2190,7 @@ pub(crate) fn sentence_forwards(
point: DisplayPoint,
mut times: usize,
) -> DisplayPoint {
let start = point.to_point(map).to_offset(&map.buffer_snapshot);
let start = point.to_point(map).to_offset(&map.buffer_snapshot());
let mut chars = map.buffer_chars_at(start).peekable();
let mut was_newline = map
@@ -2218,7 +2218,7 @@ pub(crate) fn sentence_forwards(
if times == 0 {
return map.clip_point(
start_of_next_sentence
.to_offset(&map.buffer_snapshot)
.to_offset(&map.buffer_snapshot())
.to_display_point(map),
Bias::Right,
);
@@ -2238,7 +2238,7 @@ fn next_non_blank(map: &DisplaySnapshot, start: usize) -> usize {
}
}
map.buffer_snapshot.len()
map.buffer_snapshot().len()
}
// given the offset after a ., !, or ? find the start of the next sentence.
@@ -2263,12 +2263,12 @@ fn start_of_next_sentence(map: &DisplaySnapshot, end_of_sentence: usize) -> Opti
}
}
Some(map.buffer_snapshot.len())
Some(map.buffer_snapshot().len())
}
fn go_to_line(map: &DisplaySnapshot, display_point: DisplayPoint, line: usize) -> DisplayPoint {
let point = map.display_point_to_point(display_point, Bias::Left);
let Some(mut excerpt) = map.buffer_snapshot.excerpt_containing(point..point) else {
let Some(mut excerpt) = map.buffer_snapshot().excerpt_containing(point..point) else {
return display_point;
};
let offset = excerpt.buffer().point_to_offset(
@@ -2279,12 +2279,12 @@ fn go_to_line(map: &DisplaySnapshot, display_point: DisplayPoint, line: usize) -
let buffer_range = excerpt.buffer_range();
if offset >= buffer_range.start && offset <= buffer_range.end {
let point = map
.buffer_snapshot
.buffer_snapshot()
.offset_to_point(excerpt.map_offset_from_buffer(offset));
return map.clip_point(map.point_to_display_point(point, Bias::Left), Bias::Left);
}
let mut last_position = None;
for (excerpt, buffer, range) in map.buffer_snapshot.excerpts() {
for (excerpt, buffer, range) in map.buffer_snapshot().excerpts() {
let excerpt_range = language::ToOffset::to_offset(&range.context.start, buffer)
..language::ToOffset::to_offset(&range.context.end, buffer);
if offset >= excerpt_range.start && offset <= excerpt_range.end {
@@ -2303,12 +2303,12 @@ fn go_to_line(map: &DisplaySnapshot, display_point: DisplayPoint, line: usize) -
}
}
let mut last_point = last_position.unwrap().to_point(&map.buffer_snapshot);
let mut last_point = last_position.unwrap().to_point(&map.buffer_snapshot());
last_point.column = point.column;
map.clip_point(
map.point_to_display_point(
map.buffer_snapshot.clip_point(point, Bias::Left),
map.buffer_snapshot().clip_point(point, Bias::Left),
Bias::Left,
),
Bias::Left,
@@ -2330,7 +2330,7 @@ fn start_of_document(
map.clip_point(
map.point_to_display_point(
map.buffer_snapshot.clip_point(first_point, Bias::Left),
map.buffer_snapshot().clip_point(first_point, Bias::Left),
Bias::Left,
),
Bias::Left,
@@ -2346,12 +2346,12 @@ fn end_of_document(
return go_to_line(map, display_point, times);
};
let point = map.display_point_to_point(display_point, Bias::Left);
let mut last_point = map.buffer_snapshot.max_point();
let mut last_point = map.buffer_snapshot().max_point();
last_point.column = point.column;
map.clip_point(
map.point_to_display_point(
map.buffer_snapshot.clip_point(last_point, Bias::Left),
map.buffer_snapshot().clip_point(last_point, Bias::Left),
Bias::Left,
),
Bias::Left,
@@ -2364,7 +2364,7 @@ fn matching_tag(map: &DisplaySnapshot, head: DisplayPoint) -> Option<DisplayPoin
if head > outer.start && head < inner.start {
let mut offset = inner.end.to_offset(map, Bias::Left);
for c in map.buffer_snapshot.chars_at(offset) {
for c in map.buffer_snapshot().chars_at(offset) {
if c == '/' || c == '\n' || c == '>' {
return Some(offset.to_display_point(map));
}
@@ -2372,7 +2372,7 @@ fn matching_tag(map: &DisplaySnapshot, head: DisplayPoint) -> Option<DisplayPoin
}
} else {
let mut offset = outer.start.to_offset(map, Bias::Left);
for c in map.buffer_snapshot.chars_at(offset) {
for c in map.buffer_snapshot().chars_at(offset) {
offset += c.len_utf8();
if c == '<' || c == '\n' {
return Some(offset.to_display_point(map));
@@ -2387,7 +2387,7 @@ fn matching(map: &DisplaySnapshot, display_point: DisplayPoint) -> DisplayPoint
// https://github.com/vim/vim/blob/1d87e11a1ef201b26ed87585fba70182ad0c468a/runtime/doc/motion.txt#L1200
let display_point = map.clip_at_line_end(display_point);
let point = display_point.to_point(map);
let offset = point.to_offset(&map.buffer_snapshot);
let offset = point.to_offset(&map.buffer_snapshot());
// Ensure the range is contained by the current line.
let mut line_end = map.next_line_boundary(point).0;
@@ -2396,7 +2396,7 @@ fn matching(map: &DisplaySnapshot, display_point: DisplayPoint) -> DisplayPoint
}
if let Some((opening_range, closing_range)) = map
.buffer_snapshot
.buffer_snapshot()
.innermost_enclosing_bracket_ranges(offset..offset, None)
{
if opening_range.contains(&offset) {
@@ -2409,17 +2409,17 @@ fn matching(map: &DisplaySnapshot, display_point: DisplayPoint) -> DisplayPoint
let line_range = map.prev_line_boundary(point).0..line_end;
let visible_line_range =
line_range.start..Point::new(line_range.end.row, line_range.end.column.saturating_sub(1));
let ranges = map.buffer_snapshot.bracket_ranges(visible_line_range);
let ranges = map.buffer_snapshot().bracket_ranges(visible_line_range);
if let Some(ranges) = ranges {
let line_range = line_range.start.to_offset(&map.buffer_snapshot)
..line_range.end.to_offset(&map.buffer_snapshot);
let line_range = line_range.start.to_offset(&map.buffer_snapshot())
..line_range.end.to_offset(&map.buffer_snapshot());
let mut closest_pair_destination = None;
let mut closest_distance = usize::MAX;
for (open_range, close_range) in ranges {
if map.buffer_snapshot.chars_at(open_range.start).next() == Some('<') {
if map.buffer_snapshot().chars_at(open_range.start).next() == Some('<') {
if offset > open_range.start && offset < close_range.start {
let mut chars = map.buffer_snapshot.chars_at(close_range.start);
let mut chars = map.buffer_snapshot().chars_at(close_range.start);
if (Some('/'), Some('>')) == (chars.next(), chars.next()) {
return display_point;
}
@@ -2473,7 +2473,7 @@ fn matching(map: &DisplaySnapshot, display_point: DisplayPoint) -> DisplayPoint
//
// https://neovim.io/doc/user/motion.html#N%25
fn go_to_percentage(map: &DisplaySnapshot, point: DisplayPoint, count: usize) -> DisplayPoint {
let total_lines = map.buffer_snapshot.max_point().row + 1;
let total_lines = map.buffer_snapshot().max_point().row + 1;
let target_line = (count * total_lines as usize).div_ceil(100);
let target_point = DisplayPoint::new(
DisplayRow(target_line.saturating_sub(1) as u32),
@@ -2491,16 +2491,16 @@ fn unmatched_forward(
for _ in 0..times {
// https://github.com/vim/vim/blob/1d87e11a1ef201b26ed87585fba70182ad0c468a/runtime/doc/motion.txt#L1245
let point = display_point.to_point(map);
let offset = point.to_offset(&map.buffer_snapshot);
let offset = point.to_offset(&map.buffer_snapshot());
let ranges = map.buffer_snapshot.enclosing_bracket_ranges(point..point);
let ranges = map.buffer_snapshot().enclosing_bracket_ranges(point..point);
let Some(ranges) = ranges else { break };
let mut closest_closing_destination = None;
let mut closest_distance = usize::MAX;
for (_, close_range) in ranges {
if close_range.start > offset {
let mut chars = map.buffer_snapshot.chars_at(close_range.start);
let mut chars = map.buffer_snapshot().chars_at(close_range.start);
if Some(char) == chars.next() {
let distance = close_range.start - offset;
if distance < closest_distance {
@@ -2532,9 +2532,9 @@ fn unmatched_backward(
for _ in 0..times {
// https://github.com/vim/vim/blob/1d87e11a1ef201b26ed87585fba70182ad0c468a/runtime/doc/motion.txt#L1239
let point = display_point.to_point(map);
let offset = point.to_offset(&map.buffer_snapshot);
let offset = point.to_offset(&map.buffer_snapshot());
let ranges = map.buffer_snapshot.enclosing_bracket_ranges(point..point);
let ranges = map.buffer_snapshot().enclosing_bracket_ranges(point..point);
let Some(ranges) = ranges else {
break;
};
@@ -2544,7 +2544,7 @@ fn unmatched_backward(
for (start_range, _) in ranges {
if start_range.start < offset {
let mut chars = map.buffer_snapshot.chars_at(start_range.start);
let mut chars = map.buffer_snapshot().chars_at(start_range.start);
if Some(char) == chars.next() {
let distance = offset - start_range.start;
if distance < closest_distance {
@@ -2629,7 +2629,7 @@ fn find_backward(
to = new_to;
}
let next = map.buffer_snapshot.chars_at(to.to_point(map)).next();
let next = map.buffer_snapshot().chars_at(to.to_point(map)).next();
if next.is_some() && is_character_match(target, next.unwrap(), smartcase) {
if after {
*to.column_mut() += 1;
@@ -2850,13 +2850,13 @@ fn method_motion(
direction: Direction,
is_start: bool,
) -> DisplayPoint {
let Some((_, _, buffer)) = map.buffer_snapshot.as_singleton() else {
let Some((_, _, buffer)) = map.buffer_snapshot().as_singleton() else {
return display_point;
};
for _ in 0..times {
let point = map.display_point_to_point(display_point, Bias::Left);
let offset = point.to_offset(&map.buffer_snapshot);
let offset = point.to_offset(&map.buffer_snapshot());
let range = if direction == Direction::Prev {
0..offset
} else {
@@ -2900,13 +2900,13 @@ fn comment_motion(
times: usize,
direction: Direction,
) -> DisplayPoint {
let Some((_, _, buffer)) = map.buffer_snapshot.as_singleton() else {
let Some((_, _, buffer)) = map.buffer_snapshot().as_singleton() else {
return display_point;
};
for _ in 0..times {
let point = map.display_point_to_point(display_point, Bias::Left);
let offset = point.to_offset(&map.buffer_snapshot);
let offset = point.to_offset(&map.buffer_snapshot());
let range = if direction == Direction::Prev {
0..offset
} else {
@@ -2956,22 +2956,22 @@ fn section_motion(
direction: Direction,
is_start: bool,
) -> DisplayPoint {
if map.buffer_snapshot.as_singleton().is_some() {
if map.buffer_snapshot().as_singleton().is_some() {
for _ in 0..times {
let offset = map
.display_point_to_point(display_point, Bias::Left)
.to_offset(&map.buffer_snapshot);
.to_offset(&map.buffer_snapshot());
let range = if direction == Direction::Prev {
0..offset
} else {
offset..map.buffer_snapshot.len()
offset..map.buffer_snapshot().len()
};
// we set a max start depth here because we want a section to only be "top level"
// similar to vim's default of '{' in the first column.
// (and without it, ]] at the start of editor.rs is -very- slow)
let mut possibilities = map
.buffer_snapshot
.buffer_snapshot()
.text_object_ranges(range, language::TreeSitterOptions::max_start_depth(3))
.filter(|(_, object)| {
matches!(
@@ -3003,7 +3003,7 @@ fn section_motion(
let offset = if direction == Direction::Prev {
possibilities.max().unwrap_or(0)
} else {
possibilities.min().unwrap_or(map.buffer_snapshot.len())
possibilities.min().unwrap_or(map.buffer_snapshot().len())
};
let new_point = map.clip_point(offset.to_display_point(map), Bias::Left);
+2 -2
View File
@@ -69,7 +69,7 @@ impl Vim {
let mut start_offset =
selection.start.to_offset(map, Bias::Left);
let classifier = map
.buffer_snapshot
.buffer_snapshot()
.char_classifier_at(selection.start.to_point(map));
for (ch, offset) in map.buffer_chars_at(start_offset) {
if ch == '\n' || !classifier.is_whitespace(ch) {
@@ -153,7 +153,7 @@ fn expand_changed_word_selection(
) -> Option<MotionKind> {
let is_in_word = || {
let classifier = map
.buffer_snapshot
.buffer_snapshot()
.char_classifier_at(selection.start.to_point(map));
map.buffer_chars_at(selection.head().to_offset(map, Bias::Left))
+5 -4
View File
@@ -50,12 +50,13 @@ impl Vim {
if kind == Some(MotionKind::Linewise) {
let start = selection.start.to_point(map);
let end = selection.end.to_point(map);
if end.row < map.buffer_snapshot.max_point().row {
if end.row < map.buffer_snapshot().max_point().row {
selection.end = Point::new(end.row + 1, 0).to_display_point(map)
} else if start.row > 0 {
selection.start = Point::new(
start.row - 1,
map.buffer_snapshot.line_len(MultiBufferRow(start.row - 1)),
map.buffer_snapshot()
.line_len(MultiBufferRow(start.row - 1)),
)
.to_display_point(map)
}
@@ -183,7 +184,7 @@ impl Vim {
let mut cursor_point = cursor.to_point(map);
cursor_point.column = *column;
cursor = map
.buffer_snapshot
.buffer_snapshot()
.clip_point(cursor_point, Bias::Left)
.to_display_point(map);
}
@@ -203,7 +204,7 @@ fn move_selection_end_to_next_line(map: &DisplaySnapshot, selection: &mut Select
}
fn ends_at_eof(map: &DisplaySnapshot, selection: &mut Selection<DisplayPoint>) -> bool {
selection.end.to_point(map) == map.buffer_snapshot.max_point()
selection.end.to_point(map) == map.buffer_snapshot().max_point()
}
#[cfg(test)]
+5 -5
View File
@@ -54,11 +54,11 @@ impl Vim {
for selection in selections {
let end = movement::saturating_left(&map, selection.end);
ends.push(
map.buffer_snapshot
map.buffer_snapshot()
.anchor_before(end.to_offset(&map, Bias::Left)),
);
starts.push(
map.buffer_snapshot
map.buffer_snapshot()
.anchor_before(selection.start.to_offset(&map, Bias::Left)),
);
reversed.push(selection.reversed)
@@ -106,7 +106,7 @@ impl Vim {
point = motion::first_non_whitespace(&map.display_snapshot, false, point);
anchor = map
.display_snapshot
.buffer_snapshot
.buffer_snapshot()
.anchor_before(point.to_point(&map.display_snapshot));
}
@@ -239,7 +239,7 @@ impl Vim {
point = motion::first_non_whitespace(&map.display_snapshot, false, point);
anchor = map
.display_snapshot
.buffer_snapshot
.buffer_snapshot()
.anchor_before(point.to_point(&map.display_snapshot));
}
@@ -312,7 +312,7 @@ impl Vim {
")" => motion::sentence_forwards(&map, selection.head(), 1),
_ => unreachable!(),
};
map.buffer_snapshot
map.buffer_snapshot()
.anchor_before(point.to_offset(&map, Bias::Left))
})
.collect::<Vec<Anchor>>();
+4 -2
View File
@@ -159,9 +159,11 @@ impl Vim {
let point_range = display_range.start.to_point(&display_map)
..display_range.end.to_point(&display_map);
let anchor = if is_multiline || vim.mode == Mode::VisualLine {
display_map.buffer_snapshot.anchor_before(point_range.start)
display_map
.buffer_snapshot()
.anchor_before(point_range.start)
} else {
display_map.buffer_snapshot.anchor_after(point_range.end)
display_map.buffer_snapshot().anchor_after(point_range.end)
};
if *preserve {
+3 -2
View File
@@ -263,7 +263,7 @@ impl Vim {
if prior_selections.iter().any(|s| {
self.update_editor(cx, |_, editor, cx| {
!s.start
.is_valid(&editor.snapshot(window, cx).buffer_snapshot)
.is_valid(&editor.snapshot(window, cx).buffer_snapshot())
})
.unwrap_or(true)
}) {
@@ -469,7 +469,8 @@ impl Vim {
};
if let Some(result) = self.update_editor(cx, |vim, editor, cx| {
let range = action.range.buffer_range(vim, editor, window, cx)?;
let snapshot = &editor.snapshot(window, cx).buffer_snapshot;
let snapshot = editor.snapshot(window, cx);
let snapshot = snapshot.buffer_snapshot();
let end_point = Point::new(range.end.0, snapshot.line_len(range.end));
let range = snapshot.anchor_before(Point::new(range.start.0, 0))
..snapshot.anchor_after(end_point);
+28 -22
View File
@@ -94,7 +94,7 @@ fn cover_or_next<I: Iterator<Item = (Range<usize>, Range<usize>)>>(
let caret_offset = caret.to_offset(map, Bias::Left);
let mut covering = vec![];
let mut next_ones = vec![];
let snapshot = &map.buffer_snapshot;
let snapshot = &map.buffer_snapshot();
if let Some(ranges) = candidates {
for (open_range, close_range) in ranges {
@@ -173,12 +173,12 @@ fn find_mini_delimiters(
is_valid_delimiter: &DelimiterPredicate,
) -> Option<Range<DisplayPoint>> {
let point = map.clip_at_line_end(display_point).to_point(map);
let offset = point.to_offset(&map.buffer_snapshot);
let offset = point.to_offset(&map.buffer_snapshot());
let line_range = get_line_range(map, point);
let visible_line_range = get_visible_line_range(&line_range);
let snapshot = &map.buffer_snapshot;
let snapshot = &map.buffer_snapshot();
let excerpt = snapshot.excerpt_containing(offset..offset)?;
let buffer = excerpt.buffer();
@@ -187,7 +187,7 @@ fn find_mini_delimiters(
};
// Try to find delimiters in visible range first
let ranges = map.buffer_snapshot.bracket_ranges(visible_line_range);
let ranges = map.buffer_snapshot().bracket_ranges(visible_line_range);
if let Some(candidate) = cover_or_next(ranges, display_point, map, Some(&bracket_filter)) {
return Some(
DelimiterRange {
@@ -740,7 +740,7 @@ fn in_word(
) -> Option<Range<DisplayPoint>> {
// Use motion::right so that we consider the character under the cursor when looking for the start
let classifier = map
.buffer_snapshot
.buffer_snapshot()
.char_classifier_at(relative_to.to_point(map))
.ignore_punctuation(ignore_punctuation);
let start = movement::find_preceding_boundary_display_point(
@@ -765,7 +765,7 @@ fn in_subword(
let offset = relative_to.to_offset(map, Bias::Left);
// Use motion::right so that we consider the character under the cursor when looking for the start
let classifier = map
.buffer_snapshot
.buffer_snapshot()
.char_classifier_at(relative_to.to_point(map))
.ignore_punctuation(ignore_punctuation);
let in_subword = map
@@ -838,7 +838,7 @@ pub fn surrounding_html_tag(
Some(read_tag(chars))
}
let snapshot = &map.buffer_snapshot;
let snapshot = &map.buffer_snapshot();
let offset = head.to_offset(map, Bias::Left);
let mut excerpt = snapshot.excerpt_containing(offset..offset)?;
let buffer = excerpt.buffer();
@@ -909,7 +909,7 @@ fn around_word(
) -> Option<Range<DisplayPoint>> {
let offset = relative_to.to_offset(map, Bias::Left);
let classifier = map
.buffer_snapshot
.buffer_snapshot()
.char_classifier_at(offset)
.ignore_punctuation(ignore_punctuation);
let in_word = map
@@ -932,7 +932,7 @@ fn around_subword(
) -> Option<Range<DisplayPoint>> {
// Use motion::right so that we consider the character under the cursor when looking for the start
let classifier = map
.buffer_snapshot
.buffer_snapshot()
.char_classifier_at(relative_to.to_point(map))
.ignore_punctuation(ignore_punctuation);
let start = movement::find_preceding_boundary_display_point(
@@ -991,7 +991,7 @@ fn around_next_word(
ignore_punctuation: bool,
) -> Option<Range<DisplayPoint>> {
let classifier = map
.buffer_snapshot
.buffer_snapshot()
.char_classifier_at(relative_to.to_point(map))
.ignore_punctuation(ignore_punctuation);
// Get the start of the word
@@ -1028,7 +1028,7 @@ fn text_object(
relative_to: DisplayPoint,
target: TextObject,
) -> Option<Range<DisplayPoint>> {
let snapshot = &map.buffer_snapshot;
let snapshot = &map.buffer_snapshot();
let offset = relative_to.to_offset(map, Bias::Left);
let mut excerpt = snapshot.excerpt_containing(offset..offset)?;
@@ -1073,7 +1073,7 @@ fn argument(
relative_to: DisplayPoint,
around: bool,
) -> Option<Range<DisplayPoint>> {
let snapshot = &map.buffer_snapshot;
let snapshot = &map.buffer_snapshot();
let offset = relative_to.to_offset(map, Bias::Left);
// The `argument` vim text object uses the syntax tree, so we operate at the buffer level and map back to the display level
@@ -1247,7 +1247,7 @@ fn indent(
// Loop forwards until we find a non-blank line with less indent
let mut end_row = row;
let max_rows = map.buffer_snapshot.max_row().0;
let max_rows = map.buffer_snapshot().max_row().0;
for next_row in (row + 1)..=max_rows {
let indent = map.line_indent_for_buffer_row(MultiBufferRow(next_row));
if indent.is_line_empty() {
@@ -1263,7 +1263,7 @@ fn indent(
end_row = next_row;
}
let end_len = map.buffer_snapshot.line_len(MultiBufferRow(end_row));
let end_len = map.buffer_snapshot().line_len(MultiBufferRow(end_row));
let start = map.point_to_display_point(Point::new(start_row, 0), Bias::Right);
let end = map.point_to_display_point(Point::new(end_row, end_len), Bias::Left);
Some(start..end)
@@ -1434,7 +1434,9 @@ fn paragraph(
let paragraph_end_row = paragraph_end.row();
let paragraph_ends_with_eof = paragraph_end_row == map.max_point().row();
let point = relative_to.to_point(map);
let current_line_is_empty = map.buffer_snapshot.is_line_blank(MultiBufferRow(point.row));
let current_line_is_empty = map
.buffer_snapshot()
.is_line_blank(MultiBufferRow(point.row));
if around {
if paragraph_ends_with_eof {
@@ -1472,10 +1474,12 @@ pub fn start_of_paragraph(map: &DisplaySnapshot, display_point: DisplayPoint) ->
return DisplayPoint::zero();
}
let is_current_line_blank = map.buffer_snapshot.is_line_blank(MultiBufferRow(point.row));
let is_current_line_blank = map
.buffer_snapshot()
.is_line_blank(MultiBufferRow(point.row));
for row in (0..point.row).rev() {
let blank = map.buffer_snapshot.is_line_blank(MultiBufferRow(row));
let blank = map.buffer_snapshot().is_line_blank(MultiBufferRow(row));
if blank != is_current_line_blank {
return Point::new(row + 1, 0).to_display_point(map);
}
@@ -1489,19 +1493,21 @@ pub fn start_of_paragraph(map: &DisplaySnapshot, display_point: DisplayPoint) ->
/// The trailing newline is excluded from the paragraph.
pub fn end_of_paragraph(map: &DisplaySnapshot, display_point: DisplayPoint) -> DisplayPoint {
let point = display_point.to_point(map);
if point.row == map.buffer_snapshot.max_row().0 {
if point.row == map.buffer_snapshot().max_row().0 {
return map.max_point();
}
let is_current_line_blank = map.buffer_snapshot.is_line_blank(MultiBufferRow(point.row));
let is_current_line_blank = map
.buffer_snapshot()
.is_line_blank(MultiBufferRow(point.row));
for row in point.row + 1..map.buffer_snapshot.max_row().0 + 1 {
let blank = map.buffer_snapshot.is_line_blank(MultiBufferRow(row));
for row in point.row + 1..map.buffer_snapshot().max_row().0 + 1 {
let blank = map.buffer_snapshot().is_line_blank(MultiBufferRow(row));
if blank != is_current_line_blank {
let previous_row = row - 1;
return Point::new(
previous_row,
map.buffer_snapshot.line_len(MultiBufferRow(previous_row)),
map.buffer_snapshot().line_len(MultiBufferRow(previous_row)),
)
.to_display_point(map);
}
+17 -17
View File
@@ -65,12 +65,12 @@ impl Vim {
// we don't do a replace, we need insert a "\n"
if !is_new_line {
range.end.column += 1;
range.end = map.buffer_snapshot.clip_point(range.end, Bias::Right);
range.end = map.buffer_snapshot().clip_point(range.end, Bias::Right);
}
let replace_range = map.buffer_snapshot.anchor_before(range.start)
..map.buffer_snapshot.anchor_after(range.end);
let replace_range = map.buffer_snapshot().anchor_before(range.start)
..map.buffer_snapshot().anchor_after(range.end);
let current_text = map
.buffer_snapshot
.buffer_snapshot()
.text_for_range(replace_range.clone())
.collect();
vim.replacements.push((replace_range.clone(), current_text));
@@ -111,15 +111,15 @@ impl Vim {
)
.to_point(&map);
new_selections.push(
map.buffer_snapshot.anchor_before(start)
..map.buffer_snapshot.anchor_before(start),
map.buffer_snapshot().anchor_before(start)
..map.buffer_snapshot().anchor_before(start),
);
let mut undo = None;
let edit_range = start..end;
for (i, (range, inverse)) in vim.replacements.iter().rev().enumerate() {
if range.start.to_point(&map.buffer_snapshot) <= edit_range.start
&& range.end.to_point(&map.buffer_snapshot) >= edit_range.end
if range.start.to_point(&map.buffer_snapshot()) <= edit_range.start
&& range.end.to_point(&map.buffer_snapshot()) >= edit_range.end
{
undo = Some(inverse.clone());
vim.replacements.remove(vim.replacements.len() - i - 1);
@@ -154,10 +154,10 @@ impl Vim {
let snapshot = editor.snapshot(window, cx);
object.expand_selection(&snapshot, &mut selection, around, None);
let start = snapshot
.buffer_snapshot
.buffer_snapshot()
.anchor_before(selection.start.to_point(&snapshot));
let end = snapshot
.buffer_snapshot
.buffer_snapshot()
.anchor_before(selection.end.to_point(&snapshot));
let new_range = start..end;
vim.exchange_impl(new_range, editor, &snapshot, window, cx);
@@ -206,10 +206,10 @@ impl Vim {
forced_motion,
);
let start = snapshot
.buffer_snapshot
.buffer_snapshot()
.anchor_before(selection.start.to_point(&snapshot));
let end = snapshot
.buffer_snapshot
.buffer_snapshot()
.anchor_before(selection.end.to_point(&snapshot));
let new_range = start..end;
vim.exchange_impl(new_range, editor, &snapshot, window, cx);
@@ -228,14 +228,14 @@ impl Vim {
if let Some((_, ranges)) = editor.clear_background_highlights::<VimExchange>(cx) {
let previous_range = ranges[0].clone();
let new_range_start = new_range.start.to_offset(&snapshot.buffer_snapshot);
let new_range_end = new_range.end.to_offset(&snapshot.buffer_snapshot);
let previous_range_end = previous_range.end.to_offset(&snapshot.buffer_snapshot);
let previous_range_start = previous_range.start.to_offset(&snapshot.buffer_snapshot);
let new_range_start = new_range.start.to_offset(&snapshot.buffer_snapshot());
let new_range_end = new_range.end.to_offset(&snapshot.buffer_snapshot());
let previous_range_end = previous_range.end.to_offset(&snapshot.buffer_snapshot());
let previous_range_start = previous_range.start.to_offset(&snapshot.buffer_snapshot());
let text_for = |range: Range<Anchor>| {
snapshot
.buffer_snapshot
.buffer_snapshot()
.text_for_range(range)
.collect::<String>()
};
+3 -3
View File
@@ -94,14 +94,14 @@ impl Vim {
format!("{}{}", maybe_space, pair.end),
)
};
let start_anchor = display_map.buffer_snapshot.anchor_before(start);
let start_anchor = display_map.buffer_snapshot().anchor_before(start);
edits.push((start..start, start_cursor_str));
edits.push((end..end, end_cursor_str));
anchors.push(start_anchor..start_anchor);
} else {
let start_anchor = display_map
.buffer_snapshot
.buffer_snapshot()
.anchor_before(selection.head().to_offset(&display_map, Bias::Left));
anchors.push(start_anchor..start_anchor);
}
@@ -323,7 +323,7 @@ impl Vim {
.disjoint_anchors_arc()
.iter()
.map(|selection| {
let start = selection.start.bias_left(&display_map.buffer_snapshot);
let start = selection.start.bias_left(&display_map.buffer_snapshot());
start..start
})
.collect::<Vec<_>>();
+2 -2
View File
@@ -902,7 +902,7 @@ fn assert_pending_input(cx: &mut VimTestContext, expected: &str) {
assert_eq!(
highlights
.iter()
.map(|highlight| highlight.to_offset(&snapshot.buffer_snapshot))
.map(|highlight| highlight.to_offset(&snapshot.buffer_snapshot()))
.collect::<Vec<_>>(),
ranges
)
@@ -962,7 +962,7 @@ async fn test_jk_delay(cx: &mut gpui::TestAppContext) {
assert_eq!(
highlights
.iter()
.map(|highlight| highlight.to_offset(&snapshot.buffer_snapshot))
.map(|highlight| highlight.to_offset(&snapshot.buffer_snapshot()))
.collect::<Vec<_>>(),
vec![0..1]
)
+5 -4
View File
@@ -1142,11 +1142,11 @@ impl Vim {
&& mode.is_visual()
&& !last_mode.is_visual()
{
let mut end = pending.end.to_point(&snapshot.buffer_snapshot);
let mut end = pending.end.to_point(&snapshot.buffer_snapshot());
end = snapshot
.buffer_snapshot
.buffer_snapshot()
.clip_point(end + Point::new(0, 1), Bias::Right);
pending.end = snapshot.buffer_snapshot.anchor_before(end);
pending.end = snapshot.buffer_snapshot().anchor_before(end);
}
s.move_with(|map, selection| {
@@ -1412,7 +1412,8 @@ impl Vim {
self.update_editor(cx, |_, editor, cx| {
let selection = editor.selections.newest::<usize>(cx);
let snapshot = &editor.snapshot(window, cx).buffer_snapshot;
let snapshot = editor.snapshot(window, cx);
let snapshot = snapshot.buffer_snapshot();
let (range, kind) =
snapshot.surrounding_word(selection.start, Some(CharScopeContext::Completion));
if kind == Some(CharKind::Word) {
+12 -9
View File
@@ -485,7 +485,7 @@ impl Vim {
if object == Object::Paragraph && range.start != range.end {
let row_of_selection_end_line = selection.end.to_point(map).row;
let new_selection_end = if map
.buffer_snapshot
.buffer_snapshot()
.line_len(MultiBufferRow(row_of_selection_end_line))
== 0
{
@@ -505,7 +505,7 @@ impl Vim {
if selection.end.to_point(map).row > new_start_point.row {
if original_point.column
== map
.buffer_snapshot
.buffer_snapshot()
.line_len(MultiBufferRow(original_point.row))
{
selection.start = movement::saturating_left(
@@ -635,7 +635,7 @@ impl Vim {
let row = end.row.saturating_sub(1);
selection.end = Point::new(
row,
map.buffer_snapshot.line_len(MultiBufferRow(row)),
map.buffer_snapshot().line_len(MultiBufferRow(row)),
)
.to_display_point(map)
} else {
@@ -658,12 +658,13 @@ impl Vim {
s.move_with(|map, selection| {
let end = selection.end.to_point(map);
let start = selection.start.to_point(map);
if end.row < map.buffer_snapshot.max_point().row {
if end.row < map.buffer_snapshot().max_point().row {
selection.end = Point::new(end.row + 1, 0).to_display_point(map)
} else if start.row > 0 {
selection.start = Point::new(
start.row - 1,
map.buffer_snapshot.line_len(MultiBufferRow(start.row - 1)),
map.buffer_snapshot()
.line_len(MultiBufferRow(start.row - 1)),
)
.to_display_point(map)
}
@@ -706,9 +707,11 @@ impl Vim {
let end = selection.end.to_point(map);
if end.column == 0 && end > start {
let row = end.row.saturating_sub(1);
selection.end =
Point::new(row, map.buffer_snapshot.line_len(MultiBufferRow(row)))
.to_display_point(map);
selection.end = Point::new(
row,
map.buffer_snapshot().line_len(MultiBufferRow(row)),
)
.to_display_point(map);
}
});
});
@@ -755,7 +758,7 @@ impl Vim {
.disjoint_anchors_arc()
.iter()
.map(|selection| {
let start = selection.start.bias_left(&display_map.buffer_snapshot);
let start = selection.start.bias_left(&display_map.buffer_snapshot());
start..start
})
.collect::<Vec<_>>();