Merge branch 'main' into vim-softwrap-word

This commit is contained in:
Conrad Irwin 2023-09-01 11:05:12 -07:00
commit aa7b65bbaf
111 changed files with 4173 additions and 1585 deletions

View file

@ -590,12 +590,12 @@ pub(crate) fn next_word_start(
ignore_punctuation: bool,
times: usize,
) -> DisplayPoint {
let language = map.buffer_snapshot.language_at(point.to_point(map));
let scope = map.buffer_snapshot.language_scope_at(point.to_point(map));
for _ in 0..times {
let mut crossed_newline = false;
point = movement::find_boundary(map, point, FindRange::MultiLine, |left, right| {
let left_kind = char_kind(language, left).coerce_punctuation(ignore_punctuation);
let right_kind = char_kind(language, right).coerce_punctuation(ignore_punctuation);
let left_kind = char_kind(&scope, left).coerce_punctuation(ignore_punctuation);
let right_kind = char_kind(&scope, right).coerce_punctuation(ignore_punctuation);
let at_newline = right == '\n';
let found = (left_kind != right_kind && right_kind != CharKind::Whitespace)
@ -615,7 +615,7 @@ fn next_word_end(
ignore_punctuation: bool,
times: usize,
) -> DisplayPoint {
let language = map.buffer_snapshot.language_at(point.to_point(map));
let scope = map.buffer_snapshot.language_scope_at(point.to_point(map));
for _ in 0..times {
if point.column() < map.line_len(point.row()) {
*point.column_mut() += 1;
@ -623,10 +623,9 @@ fn next_word_end(
*point.row_mut() += 1;
*point.column_mut() = 0;
}
// *point.column_mut() += 1;
point = movement::find_boundary(map, point, FindRange::MultiLine, |left, right| {
let left_kind = char_kind(language, left).coerce_punctuation(ignore_punctuation);
let right_kind = char_kind(language, right).coerce_punctuation(ignore_punctuation);
let left_kind = char_kind(&scope, left).coerce_punctuation(ignore_punctuation);
let right_kind = char_kind(&scope, right).coerce_punctuation(ignore_punctuation);
left_kind != right_kind && left_kind != CharKind::Whitespace
});
@ -652,14 +651,14 @@ fn previous_word_start(
ignore_punctuation: bool,
times: usize,
) -> DisplayPoint {
let language = map.buffer_snapshot.language_at(point.to_point(map));
let scope = map.buffer_snapshot.language_scope_at(point.to_point(map));
for _ in 0..times {
// This works even though find_preceding_boundary is called for every character in the line containing
// cursor because the newline is checked only once.
point =
movement::find_preceding_boundary(map, point, FindRange::MultiLine, |left, right| {
let left_kind = char_kind(language, left).coerce_punctuation(ignore_punctuation);
let right_kind = char_kind(language, right).coerce_punctuation(ignore_punctuation);
let left_kind = char_kind(&scope, left).coerce_punctuation(ignore_punctuation);
let right_kind = char_kind(&scope, right).coerce_punctuation(ignore_punctuation);
(left_kind != right_kind && !right.is_whitespace()) || left == '\n'
});
@ -673,7 +672,7 @@ fn first_non_whitespace(
from: DisplayPoint,
) -> DisplayPoint {
let mut last_point = start_of_line(map, display_lines, from);
let language = map.buffer_snapshot.language_at(from.to_point(map));
let scope = map.buffer_snapshot.language_scope_at(from.to_point(map));
for (ch, point) in map.chars_at(last_point) {
if ch == '\n' {
return from;
@ -681,7 +680,7 @@ fn first_non_whitespace(
last_point = point;
if char_kind(language, ch) != CharKind::Whitespace {
if char_kind(&scope, ch) != CharKind::Whitespace {
break;
}
}