aboutsummaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
authorahkrr2021-06-05 14:25:45 +0000
committerBlaž Hrastnik2021-06-05 15:01:16 +0000
commit444cd0b068f5a838caeeb7aa9c2d570fa330ce97 (patch)
tree0ffe7d6870032f84bacfda344aba9ac7423b21e0 /helix-core
parentf6a900fee1397e26c37489a3d434a9a77fbcc30a (diff)
fix: make find_prev_char and till_prev_char work
Bevore this PR `commands::find_prev_char` and `commands::till_prev_char` were triggerable through keys but `seach::find_nth_next()` was hardcoded in `_find_char`. The passed `fn` was nerver used. With this PR the passed `fn` is used. The change in search.rs resolves an off by one error in the behivor of `find_nth_prev`
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/search.rs5
1 files changed, 3 insertions, 2 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)