ap->last = FALSE;
ap->last = TRUE;
- // make sure cursor and topline are valid
- check_lnums(TRUE);
+ if (nesting == 1)
+ // make sure cursor and topline are valid
+ check_lnums(TRUE);
do_cmdline(NULL, getnextac, (void *)&patcmd,
DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT);
- // restore cursor and topline, unless they were changed
- reset_lnums();
+ if (nesting == 1)
+ // restore cursor and topline, unless they were changed
+ reset_lnums();
#ifdef FEAT_EVAL
if (eap != NULL)
call delete('Xcolorscript')
endfunc
+function On_BufFilePost()
+ doautocmd <nomodeline> User UserEvent
+endfunction
+
+func Test_terminal_nested_autocmd()
+ new
+ call setline(1, range(500))
+ $
+ let lastline = line('.')
+
+ augroup TermTest
+ autocmd BufFilePost * call On_BufFilePost()
+ autocmd User UserEvent silent
+ augroup END
+
+ let cmd = Get_cat_123_cmd()
+ let buf = term_start(cmd, #{term_finish: 'close', hidden: 1})
+ call assert_equal(lastline, line('.'))
+
+ call TermWait(buf)
+ exe buf . 'bwipe'
+ call delete('Xtext')
+ augroup TermTest
+ au!
+ augroup END
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab