diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-04-07 19:50:12 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-04-07 19:50:12 +0200 |
commit | d4863aa99e0527e9505c79cbeafc68a6832200bf (patch) | |
tree | 2ea60d3eb3f29982b5188d86c7df63665d278d72 /src/getchar.c | |
parent | 52604f2454e5369f861d3ce34764f74a0999c773 (diff) | |
download | vim-d4863aa99e0527e9505c79cbeafc68a6832200bf.zip |
patch 8.0.0548: saving the redo buffer only works one time
Problem: Saving the redo buffer only works one time, resulting in the "."
command not working well for a function call inside another
function call. (Ingo Karkat)
Solution: Save the redo buffer at every user function call. (closes #1619)
Diffstat (limited to 'src/getchar.c')
-rw-r--r-- | src/getchar.c | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/src/getchar.c b/src/getchar.c index 011648d64..c057861a6 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -42,10 +42,6 @@ static buffheader_T redobuff = {{NULL, {NUL}}, NULL, 0, 0}; static buffheader_T old_redobuff = {{NULL, {NUL}}, NULL, 0, 0}; -#if defined(FEAT_AUTOCMD) || defined(FEAT_EVAL) || defined(PROTO) -static buffheader_T save_redobuff = {{NULL, {NUL}}, NULL, 0, 0}; -static buffheader_T save_old_redobuff = {{NULL, {NUL}}, NULL, 0, 0}; -#endif static buffheader_T recordbuff = {{NULL, {NUL}}, NULL, 0, 0}; static int typeahead_char = 0; /* typeahead char that's not flushed */ @@ -521,27 +517,22 @@ CancelRedo(void) * Save redobuff and old_redobuff to save_redobuff and save_old_redobuff. * Used before executing autocommands and user functions. */ -static int save_level = 0; - void -saveRedobuff(void) +saveRedobuff(save_redo_T *save_redo) { char_u *s; - if (save_level++ == 0) - { - save_redobuff = redobuff; - redobuff.bh_first.b_next = NULL; - save_old_redobuff = old_redobuff; - old_redobuff.bh_first.b_next = NULL; + save_redo->sr_redobuff = redobuff; + redobuff.bh_first.b_next = NULL; + save_redo->sr_old_redobuff = old_redobuff; + old_redobuff.bh_first.b_next = NULL; - /* Make a copy, so that ":normal ." in a function works. */ - s = get_buffcont(&save_redobuff, FALSE); - if (s != NULL) - { - add_buff(&redobuff, s, -1L); - vim_free(s); - } + /* Make a copy, so that ":normal ." in a function works. */ + s = get_buffcont(&save_redo->sr_redobuff, FALSE); + if (s != NULL) + { + add_buff(&redobuff, s, -1L); + vim_free(s); } } @@ -550,15 +541,12 @@ saveRedobuff(void) * Used after executing autocommands and user functions. */ void -restoreRedobuff(void) +restoreRedobuff(save_redo_T *save_redo) { - if (--save_level == 0) - { - free_buff(&redobuff); - redobuff = save_redobuff; - free_buff(&old_redobuff); - old_redobuff = save_old_redobuff; - } + free_buff(&redobuff); + redobuff = save_redo->sr_redobuff; + free_buff(&old_redobuff); + old_redobuff = save_redo->sr_old_redobuff; } #endif |