aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-06-02 04:10:43 +0000
committerBlaž Hrastnik2021-06-02 04:19:40 +0000
commitc0264b9f7f87b9357fb3dac948b39aae15f1ae30 (patch)
tree9a1f4038983dfcc412bfb74f4facdc71fc619c13
parent22dad592b87c971e3263bd3cf24c9f9ac3591676 (diff)
fix: Don't allow moving past last line, fixes #30, #24
Off by 1 error
-rw-r--r--helix-core/src/movement.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/helix-core/src/movement.rs b/helix-core/src/movement.rs
index ba2e92b9..2d86473e 100644
--- a/helix-core/src/movement.rs
+++ b/helix-core/src/movement.rs
@@ -45,7 +45,7 @@ pub fn move_vertically(
let new_line = match dir {
Direction::Backward => row.saturating_sub(count),
- Direction::Forward => std::cmp::min(row.saturating_add(count), text.len_lines() - 1),
+ Direction::Forward => std::cmp::min(row.saturating_add(count), text.len_lines() - 2),
};
// convert to 0-indexed, subtract another 1 because len_chars() counts \n