commit c356db9f44a669ee66d5cc14e6968b31e1a6210e
parent c53839cefa86d231bd5fcc80d916056ac6841e29
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Mon, 15 Jul 2024 17:27:48 +0200
macro: insert it in keystroke buffer without discarding latter's contents
Instead of simply overwriting the current contents of the keystroke
buffer with the contents of the macro buffer, insert the latter's
contents at the head of the keystroke buffer.
This allows using {runmacro} in a string bind, and allows typing ahead
over a laggy connection after invoking `runmacro` (normally with M-;).
This fixes https://savannah.gnu.org/bugs/?65991.
Reported-by: Tasos Papastylianou <tpapastylianou@hotmail.com>
Bug exists since version 2.9.4, since string binds were introduced.
Diffstat:
2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/src/prototypes.h b/src/prototypes.h
@@ -595,8 +595,8 @@ linestruct *line_from_number(ssize_t number);
void record_macro(void);
void run_macro(void);
#endif
-void reserve_space_for(size_t newsize);
size_t waiting_keycodes(void);
+void put_back(int keycode);
#ifdef ENABLE_NANORC
void implant(const char *string);
#endif
diff --git a/src/winio.c b/src/winio.c
@@ -123,14 +123,9 @@ void run_macro(void)
return;
}
- if (macro_length > capacity)
- reserve_space_for(macro_length);
+ for (size_t index = macro_length; index > 0; )
+ put_back(macro_buffer[--index]);
- for (size_t i = 0; i < macro_length; i++)
- key_buffer[i] = macro_buffer[i];
-
- waiting_codes = macro_length;
- nextcodes = key_buffer;
mute_modifiers = TRUE;
}
#endif /* !NANO_TINY */