|
|
@ -34,10 +34,9 @@ pub fn move_horizontally(
|
|
|
|
let pos = range.cursor(slice);
|
|
|
|
let pos = range.cursor(slice);
|
|
|
|
|
|
|
|
|
|
|
|
// Compute the new position.
|
|
|
|
// Compute the new position.
|
|
|
|
let new_pos = if dir == Direction::Backward {
|
|
|
|
let new_pos = match dir {
|
|
|
|
nth_prev_grapheme_boundary(slice, pos, count)
|
|
|
|
Direction::Forward => nth_next_grapheme_boundary(slice, pos, count),
|
|
|
|
} else {
|
|
|
|
Direction::Backward => nth_prev_grapheme_boundary(slice, pos, count),
|
|
|
|
nth_next_grapheme_boundary(slice, pos, count)
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Compute the final new range.
|
|
|
|
// Compute the final new range.
|
|
|
@ -59,10 +58,9 @@ pub fn move_vertically(
|
|
|
|
|
|
|
|
|
|
|
|
// Compute the new position.
|
|
|
|
// Compute the new position.
|
|
|
|
let (new_pos, new_row) = {
|
|
|
|
let (new_pos, new_row) = {
|
|
|
|
let new_row = if dir == Direction::Backward {
|
|
|
|
let new_row = match dir {
|
|
|
|
row.saturating_sub(count)
|
|
|
|
Direction::Forward => (row + count).min(slice.len_lines().saturating_sub(1)),
|
|
|
|
} else {
|
|
|
|
Direction::Backward => row.saturating_sub(count),
|
|
|
|
(row + count).min(slice.len_lines().saturating_sub(1))
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let new_col = col.max(horiz as usize);
|
|
|
|
let new_col = col.max(horiz as usize);
|
|
|
|
(
|
|
|
|
(
|
|
|
|