proftime_T wait_time;
#endif
int did_save_redobuff = FALSE;
+ save_redo_T save_redo;
/*
* Quickly return if there are no autocommands for this event or
if (!ins_compl_active())
#endif
{
- saveRedobuff();
+ saveRedobuff(&save_redo);
did_save_redobuff = TRUE;
}
did_filetype = keep_filetype;
{
restore_search_patterns();
if (did_save_redobuff)
- restoreRedobuff();
+ restoreRedobuff(&save_redo);
did_filetype = FALSE;
while (au_pending_free_buf != NULL)
{
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 */
* 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);
}
}
* 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
void flush_buffers(int flush_typeahead);
void ResetRedobuff(void);
void CancelRedo(void);
-void saveRedobuff(void);
-void restoreRedobuff(void);
+void saveRedobuff(save_redo_T *save_redo);
+void restoreRedobuff(save_redo_T *save_redo);
void AppendToRedobuff(char_u *s);
void AppendToRedobuffLit(char_u *str, int len);
void AppendCharToRedobuff(int c);
call win_gotoid(dum1_id)
bwipe!
endfunc
+
+func Test_redo_in_nested_functions()
+ nnoremap g. :set opfunc=Operator<CR>g@
+ function Operator( type, ... )
+ let @x = 'XXX'
+ execute 'normal! g`[' . (a:type ==# 'line' ? 'V' : 'v') . 'g`]' . '"xp'
+ endfunction
+
+ function! Apply()
+ 5,6normal! .
+ endfunction
+
+ new
+ call setline(1, repeat(['some "quoted" text', 'more "quoted" text'], 3))
+ 1normal g.i"
+ call assert_equal('some "XXX" text', getline(1))
+ 3,4normal .
+ call assert_equal('some "XXX" text', getline(3))
+ call assert_equal('more "XXX" text', getline(4))
+ call Apply()
+ call assert_equal('some "XXX" text', getline(5))
+ call assert_equal('more "XXX" text', getline(6))
+ bwipe!
+
+ nunmap g.
+ delfunc Operator
+ delfunc Apply
+endfunc