aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/movement.rs
diff options
context:
space:
mode:
authorKirawi2021-06-05 03:49:19 +0000
committerGitHub2021-06-05 03:49:19 +0000
commitc17dcb8633550a4efde56ca5b4e2b00fbf9f45e1 (patch)
tree9ab71f76679c1735f275448768c091219e2d49c0 /helix-core/src/movement.rs
parent5a344a3ae508f571ad5427e14ffad683213bf142 (diff)
Fixing Multiple Panics (#121)
* init * wip * wip
Diffstat (limited to 'helix-core/src/movement.rs')
-rw-r--r--helix-core/src/movement.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/helix-core/src/movement.rs b/helix-core/src/movement.rs
index 387b59b1..d6745fff 100644
--- a/helix-core/src/movement.rs
+++ b/helix-core/src/movement.rs
@@ -45,7 +45,10 @@ 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() - 2),
+ Direction::Forward => std::cmp::min(
+ row.saturating_add(count),
+ text.len_lines().saturating_sub(2),
+ ),
};
// convert to 0-indexed, subtract another 1 because len_chars() counts \n