]> granicus.if.org Git - vim/commitdiff
patch 8.2.2961: keys typed during a :normal command are discarded v8.2.2961
authorBram Moolenaar <Bram@vim.org>
Mon, 7 Jun 2021 20:04:52 +0000 (22:04 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 7 Jun 2021 20:04:52 +0000 (22:04 +0200)
Problem:    Keys typed during a :normal command are discarded.
Solution:   Concatenate saved typeahead and typed kesy. (closes #8340)

src/debugger.c
src/evalfunc.c
src/ex_docmd.c
src/getchar.c
src/proto/getchar.pro
src/proto/ui.pro
src/ui.c
src/version.c

index 6f52e984d10de89235255b24bb2fb5bcc2ab52e0..9c3c4a178c2ffd20f92ddb84fd1779b7cf95a2ed 100644 (file)
@@ -140,7 +140,7 @@ do_debug(char_u *cmd)
 
        if (typeahead_saved)
        {
-           restore_typeahead(&typeaheadbuf);
+           restore_typeahead(&typeaheadbuf, TRUE);
            ignore_script = save_ignore_script;
        }
        ex_normal_busy = save_ex_normal_busy;
index d08cf43d823680911ea3ebbdd833fd7a147ff498..97f7b61070388c1efc1e437dd52fe35afd27e479 100644 (file)
@@ -5873,7 +5873,7 @@ f_inputrestore(typval_T *argvars UNUSED, typval_T *rettv)
     {
        --ga_userinput.ga_len;
        restore_typeahead((tasave_T *)(ga_userinput.ga_data)
-                                                      + ga_userinput.ga_len);
+                                                 + ga_userinput.ga_len, TRUE);
        // default return is zero == OK
     }
     else if (p_verbose > 1)
index 4aaccb593ff0bb6f70ef5c9b8034937bba31abfb..25ec9c3fdbbdb0769766f7f68b9beed693b92cf7 100644 (file)
@@ -8249,7 +8249,7 @@ save_current_state(save_state_T *sst)
 restore_current_state(save_state_T *sst)
 {
     // Restore the previous typeahead.
-    restore_typeahead(&sst->tabuf);
+    restore_typeahead(&sst->tabuf, FALSE);
 
     msg_scroll = sst->save_msg_scroll;
     restart_edit = sst->save_restart_edit;
index 3b069c4386ead10577b57426076ec325d001d4af..149bf55a0a5174753ab36ac8a6c0a70710baba25 100644 (file)
@@ -1414,9 +1414,10 @@ save_typeahead(tasave_T *tp)
 /*
  * Restore the typeahead to what it was before calling save_typeahead().
  * The allocated memory is freed, can only be called once!
+ * When "overwrite" is FALSE input typed later is kept.
  */
     void
-restore_typeahead(tasave_T *tp)
+restore_typeahead(tasave_T *tp, int overwrite UNUSED)
 {
     if (tp->typebuf_valid)
     {
@@ -1432,7 +1433,7 @@ restore_typeahead(tasave_T *tp)
     free_buff(&readbuf2);
     readbuf2 = tp->save_readbuf2;
 # ifdef USE_INPUT_BUF
-    set_input_buf(tp->save_inputbuf);
+    set_input_buf(tp->save_inputbuf, overwrite);
 # endif
 }
 
index 25aef1c01af636f50b6020f7742dc0f7dae662cc..5f07ad6c2a6ad12dbbef77f1e9e9919f39313327 100644 (file)
@@ -32,7 +32,7 @@ int typebuf_maplen(void);
 void del_typebuf(int len, int offset);
 int save_typebuf(void);
 void save_typeahead(tasave_T *tp);
-void restore_typeahead(tasave_T *tp);
+void restore_typeahead(tasave_T *tp, int overwrite);
 void openscript(char_u *name, int directly);
 void close_all_scripts(void);
 int using_script(void);
index e75be32b97c6e91c10003c9eb1818ba502677a58..f44bad1d65f58a453eb292581541d70a3120ec9d 100644 (file)
@@ -19,7 +19,7 @@ int vim_is_input_buf_empty(void);
 int vim_free_in_input_buf(void);
 int vim_used_in_input_buf(void);
 char_u *get_input_buf(void);
-void set_input_buf(char_u *p);
+void set_input_buf(char_u *p, int overwrite);
 void add_to_input_buf(char_u *s, int len);
 void add_to_input_buf_csi(char_u *str, int len);
 void trash_input_buf(void);
index a42393732fe7eed8aff6227986927646f0d2da1f..65ac626d2f12270ad7165149527098d183f54682 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -810,9 +810,10 @@ get_input_buf(void)
 /*
  * 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 @@ set_input_buf(char_u *p)
     {
        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);
index e7aa5835087b4adf40976bf49c6f8c87b45601d8..bbf13dddf5c6c9fb6ec654da819122801be8fe78 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2961,
 /**/
     2960,
 /**/