diff options
author | Matt Freitas-Stavola | 2022-10-02 19:32:30 +0000 |
---|---|---|
committer | GitHub | 2022-10-02 19:32:30 +0000 |
commit | 9d1793c45b22a6dce0a08937717887189b46c492 (patch) | |
tree | 4ca352fbe8c8c2e71eb544561516c8dd83006ee6 /helix-term/src | |
parent | 8c2cc4301742d9d759a8c2964ade0719d4b15645 (diff) |
Add pseudo_pending for t/T/f/F (#4062)
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/commands.rs | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index fb1a4b38..264ab5bb 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1086,18 +1086,27 @@ fn extend_next_long_word_end(cx: &mut Context) { extend_word_impl(cx, movement::move_next_long_word_end) } -fn will_find_char<F>(cx: &mut Context, search_fn: F, inclusive: bool, extend: bool) -where +fn will_find_char<F>( + cx: &mut Context, + search_fn: F, + inclusive: bool, + extend: bool, + pseudo_pending: &str, +) where 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. let count = cx.count(); + cx.editor.pseudo_pending = Some(pseudo_pending.to_string()); + // need to wait for next key // TODO: should this be done by grapheme rather than char? For example, // we can't properly handle the line-ending CRLF case here in terms of char. cx.on_next_key(move |cx, event| { + cx.editor.pseudo_pending = None; + let ch = match event { KeyEvent { code: KeyCode::Enter, @@ -1200,35 +1209,35 @@ fn find_prev_char_impl( } fn find_till_char(cx: &mut Context) { - will_find_char(cx, find_next_char_impl, false, false) + will_find_char(cx, find_next_char_impl, false, false, "t") } fn find_next_char(cx: &mut Context) { - will_find_char(cx, find_next_char_impl, true, false) + will_find_char(cx, find_next_char_impl, true, false, "f") } fn extend_till_char(cx: &mut Context) { - will_find_char(cx, find_next_char_impl, false, true) + will_find_char(cx, find_next_char_impl, false, true, "t") } fn extend_next_char(cx: &mut Context) { - will_find_char(cx, find_next_char_impl, true, true) + will_find_char(cx, find_next_char_impl, true, true, "f") } fn till_prev_char(cx: &mut Context) { - will_find_char(cx, find_prev_char_impl, false, false) + will_find_char(cx, find_prev_char_impl, false, false, "T") } fn find_prev_char(cx: &mut Context) { - will_find_char(cx, find_prev_char_impl, true, false) + will_find_char(cx, find_prev_char_impl, true, false, "F") } fn extend_till_prev_char(cx: &mut Context) { - will_find_char(cx, find_prev_char_impl, false, true) + will_find_char(cx, find_prev_char_impl, false, true, "T") } fn extend_prev_char(cx: &mut Context) { - will_find_char(cx, find_prev_char_impl, true, true) + will_find_char(cx, find_prev_char_impl, true, true, "F") } fn repeat_last_motion(cx: &mut Context) { |