on master help sign in
fix: Don't allow moving past last line, fixes #30, #24

Off by 1 error

commitc0264b9f7f87b9357fb3dac948b39aae15f1ae30 authorBlaž Hrastnik <blaz@mxxn.io> dateWed 2 Jun 2021, 13:10 (5 years ago) parent22dad59
1 file changed+1−1
helix-core/src/movement.rs+1−1
helix-core/src/movement.rs+1−1
@@ -45,7 +45,7 @@ pub fn move_vertically(
4545
4646 let new_line = match dir {
4747 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),
4949 };
5050
5151 // convert to 0-indexed, subtract another 1 because len_chars() counts \n