From 0851110d10d19f34deb7945d19576e20d7a9d29b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Wed, 2 Jun 2021 13:14:55 +0900 Subject: [PATCH] f/t: Check if at bounds before searching, refs #43, closes #37 --- helix-core/src/search.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/helix-core/src/search.rs b/helix-core/src/search.rs index af754ab7..55f7bf1d 100644 --- a/helix-core/src/search.rs +++ b/helix-core/src/search.rs @@ -7,6 +7,10 @@ pub fn find_nth_next( n: usize, inclusive: bool, ) -> Option { + if pos >= text.len_chars() { + return None; + } + // start searching right after pos let mut chars = text.chars_at(pos + 1);