patch 8.2.2961: keys typed during a :normal command are discarded
Problem: Keys typed during a :normal command are discarded.
Solution: Concatenate saved typeahead and typed kesy. (closes #8340)
diff --git a/src/ui.c b/src/ui.c
index a423937..65ac626 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -810,9 +810,10 @@
/*
* Restore the input buffer with a pointer returned from get_input_buf().
* The allocated memory is freed, this only works once!
+ * When "overwrite" is FALSE input typed later is kept.
*/
void
-set_input_buf(char_u *p)
+set_input_buf(char_u *p, int overwrite)
{
garray_T *gap = (garray_T *)p;
@@ -820,8 +821,17 @@
{
if (gap->ga_data != NULL)
{
- mch_memmove(inbuf, gap->ga_data, gap->ga_len);
- inbufcount = gap->ga_len;
+ if (overwrite || inbufcount + gap->ga_len >= INBUFLEN)
+ {
+ mch_memmove(inbuf, gap->ga_data, gap->ga_len);
+ inbufcount = gap->ga_len;
+ }
+ else
+ {
+ mch_memmove(inbuf + gap->ga_len, inbuf, inbufcount);
+ mch_memmove(inbuf, gap->ga_data, gap->ga_len);
+ inbufcount += gap->ga_len;
+ }
vim_free(gap->ga_data);
}
vim_free(gap);