search: poll the input stream directly, not nano's own keystroke buffer

When checking (during a Search command) whether the user has pressed
the Cancel keystroke, look at ncurses' input stream directly instead
of at nano's own keystroke buffer, because the latter may contain the
copied keystrokes of a macro and we don't want to discard those.

(This does not yet allow a Meta keystroke to be used for Cancel, but
the next commit will fix that.)

This fixes https://savannah.gnu.org/bugs/?58825.

Bug existed since version 2.9.0, since the macro was introduced.
master
Benno Schulenberg 2020-08-20 08:09:05 +02:00
parent 6469e9668b
commit 9229834935
1 changed files with 6 additions and 2 deletions

View File

@ -194,18 +194,22 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
while (TRUE) {
/* Glance at the keyboard once every second. */
if (time(NULL) - lastkbcheck > 0) {
int input = parse_kbinput(edit);
int input = wgetch(edit);
lastkbcheck = time(NULL);
meta_key = FALSE;
/* Consume all waiting keystrokes until a Cancel. */
while (input != ERR) {
if (func_from_key(&input) == do_cancel) {
statusbar(_("Cancelled"));
/* Clear out the key buffer (in case a macro is running). */
while (input != ERR)
input = parse_kbinput(NULL);
enable_waiting();
return -2;
}
input = parse_kbinput(NULL);
input = wgetch(edit);
}
if (++feedback > 0)