From 9b2ea0151510d610bcd3e4cdf01a10e4f241a680 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 12 Nov 2022 12:26:28 +0100 Subject: Only accept keys that can actually match an existing hint. Not arbitrary keys from hintchars. Avoids unnecessary backspacing on typos. --- reselect | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); } -- cgit v1.2.3