From 9407f21fd73ec495bc42b1f1fd280bc546f729a0 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Fri, 23 Jun 2023 13:13:10 +0200 Subject: [PATCH] No error out on empty CmdlineEnter autocommand Save and Restore ex_pressedreturn when calling autocommands. fixes #12578 --- src/autocmd.c | 9 +++++++++ src/testdir/test_ex_mode.vim | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/src/autocmd.c b/src/autocmd.c index 862ddf7ccc9fa..6c99500b9e090 100644 --- a/src/autocmd.c +++ b/src/autocmd.c @@ -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; /* @@ -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 diff --git a/src/testdir/test_ex_mode.vim b/src/testdir/test_ex_mode.vim index d03ec8f2d81db..59c28f3836187 100644 --- a/src/testdir/test_ex_mode.vim +++ b/src/testdir/test_ex_mode.vim @@ -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