From 73392909006de74e628323cde915b107244a247b Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 11 May 2021 21:10:14 -0400 Subject: vim-patch:8.2.1000: get error when leaving Ex mode with :visual Problem: Get error when leaving Ex mode with :visual and a CmdLineEnter autocommand was used. Solution: Reset ex_pressedreturn. (closes vim/vim#6293) https://github.com/vim/vim/commit/158ea175a99fc23eae1b0a5ee9a81cdd973854a6 --- src/nvim/ex_docmd.c | 1 + src/nvim/testdir/test_ex_mode.vim | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 555029c1fb..87e482620c 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -7305,6 +7305,7 @@ do_exedit( if (exmode_active && (eap->cmdidx == CMD_visual || eap->cmdidx == CMD_view)) { exmode_active = FALSE; + ex_pressedreturn = false; if (*eap->arg == NUL) { /* Special case: ":global/pat/visual\NLvi-commands" */ if (global_busy) { diff --git a/src/nvim/testdir/test_ex_mode.vim b/src/nvim/testdir/test_ex_mode.vim index 87c23a2fe8..f70cb261e0 100644 --- a/src/nvim/testdir/test_ex_mode.vim +++ b/src/nvim/testdir/test_ex_mode.vim @@ -54,3 +54,29 @@ func Test_ex_mode() set sw& let &encoding = encoding_save endfunc + +func Test_ex_mode_errors() + " Not allowed to enter ex mode when text is locked + au InsertCharPre normal! gQ + let caught_e523 = 0 + try + call feedkeys("ix\", 'xt') + catch /^Vim\%((\a\+)\)\=:E523/ " catch E523 + let caught_e523 = 1 + endtry + call assert_equal(1, caught_e523) + au! InsertCharPre + + new + au CmdLineEnter * call ExEnterFunc() + func ExEnterFunc() + + endfunc + call feedkeys("gQvi\r", 'xt') + + au! CmdLineEnter + delfunc ExEnterFunc + quit +endfunc + +" vim: shiftwidth=2 sts=2 expandtab -- cgit