input: store keystroke in macro buffer only when about to interpret it

When the keystroke after the keystroke bound to `recordmacro` arrived
so quickly that the two got stored together in nano's keystroke buffer,
the main loop had not yet interpreted the `recordmacro` command and had
thus not yet set 'recording' to true, meaning that that second keystroke
would not get recorded.

Nano should record keystrokes into the macro buffer when fetching them
from its own keystroke buffer, not when fetching them from ncurses.

This fixes https://savannah.gnu.org/bugs/?65394.
The issue was reported by `correctmost`.

Bug existed since version 2.9.0, since macros were introduced.
This commit is contained in:
Benno Schulenberg 2024-03-02 16:49:27 +01:00
parent 3098315e05
commit 191cf671be
1 changed files with 5 additions and 4 deletions

View File

@ -290,10 +290,6 @@ void read_keys_from(WINDOW *frame)
napms(20);
while (TRUE) {
#ifndef NANO_TINY
if (recording)
add_to_macrobuffer(input);
#endif
input = wgetch(frame);
/* If there aren't any more characters, stop reading. */
@ -1373,6 +1369,11 @@ int get_kbinput(WINDOW *frame, bool showcursor)
while (kbinput == ERR)
kbinput = parse_kbinput(frame);
#ifndef NANO_TINY
if (recording)
add_to_macrobuffer(kbinput);
#endif
/* If we read from the edit window, blank the status bar if needed. */
if (frame == midwin)
check_statusblank();