aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-11-12 12:26:28 +0100
committerAnton Khirnov <anton@khirnov.net>2022-11-12 12:26:28 +0100
commit9b2ea0151510d610bcd3e4cdf01a10e4f241a680 (patch)
tree87680bf5ddc03b9e141eaf0671ebf1b9de75532b
parent174e130767c13cfa7170100d32b1aba289bec78d (diff)
Only accept keys that can actually match an existing hint.HEADmaster
Not arbitrary keys from hintchars. Avoids unnecessary backspacing on typos.
-rw-r--r--reselect4
1 files changed, 3 insertions, 1 deletions
diff --git a/reselect b/reselect
index 073f6d7..60f2571 100644
--- a/reselect
+++ b/reselect
@@ -201,7 +201,9 @@ sub on_key_press {
my $match = $results->{$num}->{match};
$self->launch($match);
}
- } elsif (grep { $_ eq $keyname } @hintchars) {
+ } elsif (length($keyname) == 1 &&
+ grep { index($_, $p->{buffer} . $keyname) == 0} keys %{$p->{results}}) {
+ # accept key only if the new buffer is a prefix of at least one hint
$p->{buffer} = $p->{buffer} . $keyname;
$self->update($p);
}