@@ -34,10 +34,9 @@ pub fn move_horizontally(
34 let pos = range.cursor(slice);
34 let pos = range.cursor(slice);
36 // Compute the new position.
36 // Compute the new position.
37− let new_pos = if dir == Direction::Backward {
37+ let new_pos = match dir {
38+ Direction::Forward => nth_next_grapheme_boundary(slice, pos, count),
38− nth_prev_grapheme_boundary(slice, pos, count)
39+ Direction::Backward => nth_prev_grapheme_boundary(slice, pos, count),
40− nth_next_grapheme_boundary(slice, pos, count)
43 // Compute the final new range.
42 // Compute the final new range.
@@ -59,10 +58,9 @@ pub fn move_vertically(
60 // Compute the new position.
59 // Compute the new position.
61 let (new_pos, new_row) = {
60 let (new_pos, new_row) = {
62− let new_row = if dir == Direction::Backward {
61+ let new_row = match dir {
63− row.saturating_sub(count)
65− (row + count).min(slice.len_lines().saturating_sub(1))
62+ Direction::Forward => (row + count).min(slice.len_lines().saturating_sub(1)),
63+ Direction::Backward => row.saturating_sub(count),
67 let new_col = col.max(horiz as usize);
65 let new_col = col.max(horiz as usize);