diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-06-07 22:04:52 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-06-07 22:04:52 +0200 |
commit | c41badb748bbaa78cbadfcda9ca965e8a283fb9b (patch) | |
tree | 01240bdb613c21b0b5648361c7716032ebff49ec /src | |
parent | 8cf02e5cf8fb14a5009f12e7af0a47617a0ce88d (diff) | |
download | vim-git-c41badb748bbaa78cbadfcda9ca965e8a283fb9b.tar.gz |
patch 8.2.2961: keys typed during a :normal command are discardedv8.2.2961
Problem: Keys typed during a :normal command are discarded.
Solution: Concatenate saved typeahead and typed kesy. (closes #8340)
Diffstat (limited to 'src')
-rw-r--r-- | src/debugger.c | 2 | ||||
-rw-r--r-- | src/evalfunc.c | 2 | ||||
-rw-r--r-- | src/ex_docmd.c | 2 | ||||
-rw-r--r-- | src/getchar.c | 5 | ||||
-rw-r--r-- | src/proto/getchar.pro | 2 | ||||
-rw-r--r-- | src/proto/ui.pro | 2 | ||||
-rw-r--r-- | src/ui.c | 16 | ||||
-rw-r--r-- | src/version.c | 2 |
8 files changed, 23 insertions, 10 deletions
diff --git a/src/debugger.c b/src/debugger.c index 6f52e984d..9c3c4a178 100644 --- a/src/debugger.c +++ b/src/debugger.c @@ -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; diff --git a/src/evalfunc.c b/src/evalfunc.c index d08cf43d8..97f7b6107 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -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) diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 4aaccb593..25ec9c3fd 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -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; diff --git a/src/getchar.c b/src/getchar.c index 3b069c438..149bf55a0 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -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 } diff --git a/src/proto/getchar.pro b/src/proto/getchar.pro index 25aef1c01..5f07ad6c2 100644 --- a/src/proto/getchar.pro +++ b/src/proto/getchar.pro @@ -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); diff --git a/src/proto/ui.pro b/src/proto/ui.pro index e75be32b9..f44bad1d6 100644 --- a/src/proto/ui.pro +++ b/src/proto/ui.pro @@ -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); @@ -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); diff --git a/src/version.c b/src/version.c index e7aa58350..bbf13dddf 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2961, +/**/ 2960, /**/ 2959, |