Skip to content

Commit

Permalink
No error out on empty CmdlineEnter autocommand
Browse files Browse the repository at this point in the history
Save and Restore ex_pressedreturn when calling autocommands.

fixes vim#12578
  • Loading branch information
chrisbra committed Jun 25, 2023
1 parent 982ded6 commit 9407f21
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/autocmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2019,6 +2019,9 @@ apply_autocmds_group(
save_redo_T save_redo;
int save_KeyTyped = KeyTyped;
int save_did_emsg;
#if defined(FEAT_TIMERS) || defined(PROTO)
int save_ex_pressedreturn;
#endif
ESTACK_CHECK_DECLARATION;

/*
Expand Down Expand Up @@ -2311,11 +2314,17 @@ apply_autocmds_group(
check_lnums_nested(TRUE);

save_did_emsg = did_emsg;
#if defined(FEAT_TIMERS) || defined(PROTO)
save_ex_pressedreturn = get_pressedreturn();
#endif

do_cmdline(NULL, getnextac, (void *)&patcmd,
DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT);

did_emsg += save_did_emsg;
#if defined(FEAT_TIMERS) || defined(PROTO)
set_pressedreturn(save_ex_pressedreturn);
#endif

if (nesting == 1)
// restore cursor and topline, unless they were changed
Expand Down
6 changes: 6 additions & 0 deletions src/testdir/test_ex_mode.vim
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ func Test_ex_mode_errors()

au! CmdLineEnter
delfunc ExEnterFunc

au CmdlineEnter * :
call feedkeys("gQecho 1\r", 'xt')

au! CmdlineEnter

quit
endfunc

Expand Down

0 comments on commit 9407f21

Please sign in to comment.