on master help sign in
fix: Don't allow moving past last line, fixes #30, #24
c0264b9Blaž Hrastnik
helix-core/src/movement.rs+1−1
@@ -45,7 +45,7 @@ pub fn move_vertically(
45
45
46 let new_line = match dir {
46 let new_line = match dir {
47 Direction::Backward => row.saturating_sub(count),
47 Direction::Backward => row.saturating_sub(count),
48− Direction::Forward => std::cmp::min(row.saturating_add(count), text.len_lines() - 1),
48+ Direction::Forward => std::cmp::min(row.saturating_add(count), text.len_lines() - 2),
49 };
49 };
50
50
51 // convert to 0-indexed, subtract another 1 because len_chars() counts \n
51 // convert to 0-indexed, subtract another 1 because len_chars() counts \n