on master help sign in
Minor cleanup of the vertical movement code.
aead4e6Nathan Vegdahl
helix-core/src/movement.rs+5−10
@@ -57,17 +57,12 @@ pub fn move_vertically(
57 let horiz = range.horiz.unwrap_or(col as u32);
57 let horiz = range.horiz.unwrap_or(col as u32);
58
58
59 // Compute the new position.
59 // Compute the new position.
60− let (new_pos, new_row) = {
61− let new_row = match dir {
60+ let new_row = match dir {
62− Direction::Forward => (row + count).min(slice.len_lines().saturating_sub(1)),
61+ Direction::Forward => (row + count).min(slice.len_lines().saturating_sub(1)),
63− Direction::Backward => row.saturating_sub(count),
62+ 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− )
70 };
63 };
64+ let new_col = col.max(horiz as usize);
65+ let new_pos = pos_at_coords(slice, Position::new(new_row, new_col), true);
71
66
72 // Special-case to avoid moving to the end of the last non-empty line.
67 // Special-case to avoid moving to the end of the last non-empty line.
73 if behaviour == Movement::Extend && slice.line(new_row).len_chars() == 0 {
68 if behaviour == Movement::Extend && slice.line(new_row).len_chars() == 0 {