on master help sign in
Minor cleanup of the vertical movement code.
commitaead4e69a66ba004aa34e5a1a59e05239117250e authorNathan Vegdahl <cessen@cessen.com> dateMon 26 Jul 2021, 23:20 (5 years ago) parent84f8167
1 file changed+5−10
helix-core/src/movement.rs+5−10
helix-core/src/movement.rs+5−10
@@ -57,17 +57,12 @@ pub fn move_vertically(
5757 let horiz = range.horiz.unwrap_or(col as u32);
5858
5959 // Compute the new position.
60− let (new_pos, new_row) = {
61− let new_row = match dir {
62− Direction::Forward => (row + count).min(slice.len_lines().saturating_sub(1)),
63− Direction::Backward => row.saturating_sub(count),
64− };
65− let new_col = col.max(horiz as usize);
66− (
67− pos_at_coords(slice, Position::new(new_row, new_col), true),
68− new_row,
69− )
60+ let new_row = match dir {
61+ Direction::Forward => (row + count).min(slice.len_lines().saturating_sub(1)),
62+ Direction::Backward => row.saturating_sub(count),
7063 };
64+ let new_col = col.max(horiz as usize);
65+ let new_pos = pos_at_coords(slice, Position::new(new_row, new_col), true);
7166
7267 // Special-case to avoid moving to the end of the last non-empty line.
7368 if behaviour == Movement::Extend && slice.line(new_row).len_chars() == 0 {