diff options
-rw-r--r-- | helix-core/src/search.rs | 5 | ||||
-rw-r--r-- | helix-term/src/commands.rs | 4 |
2 files changed, 5 insertions, 4 deletions
diff --git a/helix-core/src/search.rs b/helix-core/src/search.rs index 55f7bf1d..7dd2f4fc 100644 --- a/helix-core/src/search.rs +++ b/helix-core/src/search.rs @@ -41,7 +41,8 @@ pub fn find_nth_prev( inclusive: bool, ) -> Option<usize> { // start searching right before pos - let mut chars = text.chars_at(pos.saturating_sub(1)); + pos = pos.saturating_sub(1); + let mut chars = text.chars_at(pos); for _ in 0..n { loop { @@ -56,7 +57,7 @@ pub fn find_nth_prev( } if !inclusive { - pos -= 1; + pos += 1; } Some(pos) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 12ec5e19..bff102dc 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -315,7 +315,7 @@ fn _find_char<F>(cx: &mut Context, search_fn: F, inclusive: bool, extend: bool) where // TODO: make an options struct for and abstract this Fn into a searcher type // use the definition for w/b/e too - F: Fn(RopeSlice, char, usize, usize, bool) -> Option<usize>, + F: Fn(RopeSlice, char, usize, usize, bool) -> Option<usize> + 'static, { // TODO: count is reset to 1 before next key so we move it into the closure here. // Would be nice to carry over. @@ -332,7 +332,7 @@ where let text = doc.text().slice(..); let selection = doc.selection(view.id).transform(|mut range| { - search::find_nth_next(text, ch, range.head, count, inclusive).map_or(range, |pos| { + search_fn(text, ch, range.head, count, inclusive).map_or(range, |pos| { if extend { Range::new(range.anchor, pos) } else { |