move non-softwrap logic to seperate function, call this in nvim-scroll fn

pull/8015/head
alexanderdickie 10 months ago
parent 1fe59eae05
commit e4905729c3

@ -64,6 +64,28 @@ pub fn move_vertically_visual(
if !text_fmt.soft_wrap { if !text_fmt.soft_wrap {
return move_vertically(slice, range, dir, count, behaviour, text_fmt, annotations); return move_vertically(slice, range, dir, count, behaviour, text_fmt, annotations);
} }
annotations.clear_line_annotations();
return _move_vertically_visual(
slice,
range,
dir,
count,
behaviour,
text_fmt,
annotations,
);
}
pub fn _move_vertically_visual(
slice: RopeSlice,
range: Range,
dir: Direction,
count: usize,
behaviour: Movement,
text_fmt: &TextFormat,
annotations: &mut TextAnnotations
) -> Range {
let pos = range.cursor(slice); let pos = range.cursor(slice);
// Compute the current position's 2d coordinates. // Compute the current position's 2d coordinates.
@ -111,6 +133,7 @@ pub fn move_vertically(
text_fmt: &TextFormat, text_fmt: &TextFormat,
annotations: &mut TextAnnotations, annotations: &mut TextAnnotations,
) -> Range { ) -> Range {
annotations.clear_line_annotations();
let pos = range.cursor(slice); let pos = range.cursor(slice);
let line_idx = slice.char_to_line(pos); let line_idx = slice.char_to_line(pos);
let line_start = slice.line_to_char(line_idx); let line_start = slice.line_to_char(line_idx);

@ -18,7 +18,7 @@ use helix_core::{
indent::IndentStyle, indent::IndentStyle,
line_ending::{get_line_ending_of_str, line_end_char_index, str_is_line_ending}, line_ending::{get_line_ending_of_str, line_end_char_index, str_is_line_ending},
match_brackets, match_brackets,
movement::{self, move_vertically_visual, Direction}, movement::{self, move_vertically_visual, _move_vertically_visual, Direction},
object, pos_at_coords, object, pos_at_coords,
regex::{self, Regex, RegexBuilder}, regex::{self, Regex, RegexBuilder},
search::{self, CharMatcher}, search::{self, CharMatcher},
@ -599,7 +599,6 @@ fn move_impl(cx: &mut Context, move_fn: MoveFn, dir: Direction, behaviour: Movem
let text = doc.text().slice(..); let text = doc.text().slice(..);
let text_fmt = doc.text_format(view.inner_area(doc).width, None); let text_fmt = doc.text_format(view.inner_area(doc).width, None);
let mut annotations = view.text_annotations(doc, None); let mut annotations = view.text_annotations(doc, None);
annotations.clear_line_annotations();
let selection = doc.selection(view.id).clone().transform(|range| { let selection = doc.selection(view.id).clone().transform(|range| {
move_fn( move_fn(
@ -1544,7 +1543,7 @@ pub fn scroll_page_and_cursor(cx: &mut Context, offset: usize, direction: Direct
} }
let selection = doc.selection(view.id).clone().transform(|range| { let selection = doc.selection(view.id).clone().transform(|range| {
move_vertically_visual( _move_vertically_visual(
doc_text, doc_text,
range, range,
direction, direction,

Loading…
Cancel
Save