Skip to content

Commit b15213f

Browse files
mbStavolapathwave
authored andcommitted
Add pseudo_pending for t/T/f/F (helix-editor#4062)
1 parent 326e810 commit b15213f

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

helix-term/src/commands.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,18 +1089,27 @@ fn extend_next_long_word_end(cx: &mut Context) {
10891089
extend_word_impl(cx, movement::move_next_long_word_end)
10901090
}
10911091

1092-
fn will_find_char<F>(cx: &mut Context, search_fn: F, inclusive: bool, extend: bool)
1093-
where
1092+
fn will_find_char<F>(
1093+
cx: &mut Context,
1094+
search_fn: F,
1095+
inclusive: bool,
1096+
extend: bool,
1097+
pseudo_pending: &str,
1098+
) where
10941099
F: Fn(RopeSlice, char, usize, usize, bool) -> Option<usize> + 'static,
10951100
{
10961101
// TODO: count is reset to 1 before next key so we move it into the closure here.
10971102
// Would be nice to carry over.
10981103
let count = cx.count();
10991104

1105+
cx.editor.pseudo_pending = Some(pseudo_pending.to_string());
1106+
11001107
// need to wait for next key
11011108
// TODO: should this be done by grapheme rather than char? For example,
11021109
// we can't properly handle the line-ending CRLF case here in terms of char.
11031110
cx.on_next_key(move |cx, event| {
1111+
cx.editor.pseudo_pending = None;
1112+
11041113
let ch = match event {
11051114
KeyEvent {
11061115
code: KeyCode::Enter,
@@ -1203,35 +1212,35 @@ fn find_prev_char_impl(
12031212
}
12041213

12051214
fn find_till_char(cx: &mut Context) {
1206-
will_find_char(cx, find_next_char_impl, false, false)
1215+
will_find_char(cx, find_next_char_impl, false, false, "t")
12071216
}
12081217

12091218
fn find_next_char(cx: &mut Context) {
1210-
will_find_char(cx, find_next_char_impl, true, false)
1219+
will_find_char(cx, find_next_char_impl, true, false, "f")
12111220
}
12121221

12131222
fn extend_till_char(cx: &mut Context) {
1214-
will_find_char(cx, find_next_char_impl, false, true)
1223+
will_find_char(cx, find_next_char_impl, false, true, "t")
12151224
}
12161225

12171226
fn extend_next_char(cx: &mut Context) {
1218-
will_find_char(cx, find_next_char_impl, true, true)
1227+
will_find_char(cx, find_next_char_impl, true, true, "f")
12191228
}
12201229

12211230
fn till_prev_char(cx: &mut Context) {
1222-
will_find_char(cx, find_prev_char_impl, false, false)
1231+
will_find_char(cx, find_prev_char_impl, false, false, "T")
12231232
}
12241233

12251234
fn find_prev_char(cx: &mut Context) {
1226-
will_find_char(cx, find_prev_char_impl, true, false)
1235+
will_find_char(cx, find_prev_char_impl, true, false, "F")
12271236
}
12281237

12291238
fn extend_till_prev_char(cx: &mut Context) {
1230-
will_find_char(cx, find_prev_char_impl, false, true)
1239+
will_find_char(cx, find_prev_char_impl, false, true, "T")
12311240
}
12321241

12331242
fn extend_prev_char(cx: &mut Context) {
1234-
will_find_char(cx, find_prev_char_impl, true, true)
1243+
will_find_char(cx, find_prev_char_impl, true, true, "F")
12351244
}
12361245

12371246
fn repeat_last_motion(cx: &mut Context) {

0 commit comments

Comments
 (0)