Skip to content

Commit

Permalink
add anchored move edge case to unit tests
Browse files Browse the repository at this point in the history
In case soft-wrap is enabled and the newline character is wrapped into
the next line, the current implementation breaks.
  • Loading branch information
pantos9000 committed Apr 24, 2024
1 parent 8f47e3b commit 09a99c8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion helix-core/src/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ mod test {
let mut text_fmt = TextFormat::default();
text_fmt.soft_wrap = true;
text_fmt.viewport_width = 4;
let text = Rope::from("aaaabb\naa\n\n");
let text = Rope::from("aaaabb\naa\n\naaaa\n\n");
let slice = text.slice(..);
let pos = pos_at_coords(slice, (0, 5).into(), true);
let mut range = Range::new(pos, pos);
Expand All @@ -950,6 +950,14 @@ mod test {
assert_eq!(coords_at_pos(slice, range.head), (1, 1).into());
range = vvmove(range, Direction::Forward);
assert_eq!(coords_at_pos(slice, range.head), (2, 0).into());
range = vvmove(range, Direction::Forward);
assert_eq!(coords_at_pos(slice, range.head), (3, 3).into());
range = vvmove(range, Direction::Forward);
assert_eq!(coords_at_pos(slice, range.head), (4, 0).into());
range = vvmove(range, Direction::Backward);
assert_eq!(coords_at_pos(slice, range.head), (3, 3).into());
range = vvmove(range, Direction::Backward);
assert_eq!(coords_at_pos(slice, range.head), (4, 0).into());
range = vvmove(range, Direction::Backward);
assert_eq!(coords_at_pos(slice, range.head), (1, 1).into());
range = vvmove(range, Direction::Backward);
Expand Down

0 comments on commit 09a99c8

Please sign in to comment.