commit 9229834935273415d143f3e00eb17cc86201c924
parent 6469e9668b5328600ef9e48d901886be12b0315e
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 20 Aug 2020 08:09:05 +0200
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.
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/search.c b/src/search.c
@@ -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)