From e7ba32529861e2c843ad7d5fc2d2d505a9412108 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 13 Oct 2018 21:43:43 -0400 Subject: [PATCH 1/2] vim-patch:8.0.1672: error during completion causes command to be cancelled Problem: Error during completion causes command to be cancelled. Solution: Reset did_emsg before waiting for another character. (Tom M.) https://github.com/vim/vim/commit/72532d354e699f1cceec34c0b08e1de4d3ea9641 --- src/nvim/ex_getln.c | 4 ++++ src/nvim/testdir/test_cmdline.vim | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 247b9175aa..f40131177e 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -510,6 +510,10 @@ static int command_line_check(VimState *state) // completion may switch it on. quit_more = false; // reset after CTRL-D which had a more-prompt + did_emsg = false; // There can't really be a reason why an error + // that occurs while typing a command should + // cause the command not to be executed. + cursorcmd(); // set the cursor on the right spot ui_cursor_shape(); return 1; diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index c302948ba3..26f1dcc333 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -334,6 +334,17 @@ func Test_paste_in_cmdline() call feedkeys(":\etoupper(getline(1))\\\"\", 'tx') call assert_equal('"ASDF.X /TMP/SOME VERYLONGWORD A;B-C*D ', @:) bwipe! + + " Error while typing a command used to cause that it was not executed + " in the end. + new + try + call feedkeys(":file \%Xtestfile\", 'tx') + catch /^Vim\%((\a\+)\)\=:E32/ + " ignore error E32 + endtry + call assert_equal("Xtestfile", bufname("%")) + bwipe! endfunc func Test_remove_char_in_cmdline() From 9c2d5f1a33ccf3838899425ede481c6cdb00acb5 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 14 Oct 2018 04:22:40 -0400 Subject: [PATCH 2/2] functionaltest: map error does not cancel prompt --- test/functional/ui/cmdline_highlight_spec.lua | 14 +++++++------- test/functional/ui/inccommand_spec.lua | 7 +++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 5d9fffdf23..4db7720c2c 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -831,7 +831,7 @@ describe('Ex commands coloring support', function() | ]]) end) - it('does not prevent mapping error from cancelling prompt', function() + it('does prevent mapping error from cancelling prompt', function() command("cnoremap x execute('throw 42')[-1]") feed(':#x') screen:expect([[ @@ -846,14 +846,14 @@ describe('Ex commands coloring support', function() ]]) feed('') screen:expect([[ - ^ | {EOB:~ }| {EOB:~ }| {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - | + :# | + {ERR:Error detected while processing :} | + {ERR:E605: Exception not caught: 42} | + {ERR:E749: empty buffer} | + {PE:Press ENTER or type command to continue}^ | ]]) feed('') screen:expect([[ @@ -866,7 +866,7 @@ describe('Ex commands coloring support', function() {EOB:~ }| | ]]) - eq('Error detected while processing :\nE605: Exception not caught: 42', + eq('Error detected while processing :\nE605: Exception not caught: 42\nE749: empty buffer', meths.command_output('messages')) end) it('errors out when failing to get callback', function() diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 6a17448582..49b566e5a2 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -1503,7 +1503,7 @@ describe("'inccommand' and :cnoremap", function() end end) - it('does not work with a failing mapping', function() + it('does work with a failing mapping', function() for _, case in pairs(cases) do refresh(case) feed_command("cnoremap x execute('bwipeout!')[-1].'x'") @@ -1512,7 +1512,10 @@ describe("'inccommand' and :cnoremap", function() -- error thrown b/c of the mapping neq(nil, eval('v:errmsg'):find('^E523:')) - expect(default_text) + expect([[ + Inc substitution on + toxo lines + ]]) end end)