From c0264b9f7f87b9357fb3dac948b39aae15f1ae30 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Wed, 2 Jun 2021 13:10:43 +0900 Subject: fix: Don't allow moving past last line, fixes #30, #24 Off by 1 error --- helix-core/src/movement.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'helix-core') 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 -- cgit v1.2.3-70-g09d2