From 3ace581191e9c23aae23d7aabacd29c6b8ed7f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Wed, 2 Jun 2021 13:12:11 +0900 Subject: [PATCH] Fix panics when triggering w or e on the last char of the line Closes #32 --- helix-core/src/movement.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helix-core/src/movement.rs b/helix-core/src/movement.rs index 2d86473e4..f7c7786af 100644 --- a/helix-core/src/movement.rs +++ b/helix-core/src/movement.rs @@ -64,7 +64,7 @@ pub fn move_next_word_start(slice: RopeSlice, mut begin: usize, count: usize) -> let mut end = begin; for _ in 0..count { - if begin + 1 == slice.len_chars() { + if begin + 2 > slice.len_chars() { return None; } @@ -134,7 +134,7 @@ pub fn move_next_word_end(slice: RopeSlice, mut begin: usize, count: usize) -> O let mut end = begin; for _ in 0..count { - if begin + 1 == slice.len_chars() { + if begin + 2 > slice.len_chars() { return None; }