diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 469b7f0d06..bfe01c1cf9 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1387,7 +1387,8 @@ static int command_line_execute(VimState *state, int key) int wild_type = 0; const bool key_is_wc = (s->c == p_wc && KeyTyped) || s->c == p_wcm; - if ((cmdline_pum_active() || wild_menu_showing || s->did_wild_list) && !key_is_wc) { + if ((cmdline_pum_active() || wild_menu_showing || s->did_wild_list) + && !key_is_wc && s->xpc.xp_numfiles > 0) { // Ctrl-Y: Accept the current selection and close the popup menu. // Ctrl-E: cancel the cmdline popup menu and return the original text. if (s->c == Ctrl_E || s->c == Ctrl_Y) { diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim index ad164ce212..08d3ee774b 100644 --- a/test/old/testdir/test_cmdline.vim +++ b/test/old/testdir/test_cmdline.vim @@ -166,6 +166,16 @@ func Test_complete_wildmenu() call feedkeys(":sign un zz\\\\\\ yy\\"\", 'tx') call assert_equal('"sign unplace yy zz', @:) + " This used to crash + call feedkeys(":sign un\\\\\\"\", 'tx') + " Ctrl-Y is inserted literally like before 9.1.1714 + call assert_equal("\"sign undefine unplace\", @:) + " Also test Ctrl-Y after Ctrl-A with selected item (the result is the same) + call feedkeys(":sign un\\\\\"\", 'tx') + call assert_equal("\"sign undefine unplace\", @:) + call feedkeys(":sign un\\\\\\"\", 'tx') + call assert_equal("\"sign undefine unplace\", @:) + " cleanup %bwipe set nowildmenu