From 22e3b155f4b34ab54aacda6c0c96c69780e2b587 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 14 Jan 2023 17:23:24 +0800 Subject: vim-patch:partial:8.2.4339: CTRL-A does not work properly with the cmdline popup menu (#21791) Problem: CTRL-A does not work properly with the cmdline popup menu. Solution: Fix issues with CTRL-A. Add more tests for the cmdline popup menu. Remove TermWait() before VeriryScreenDump(). Refactor the cmdline popup code. (Yegappan Lakshmanan, closes vim/vim#9735) https://github.com/vim/vim/commit/560dff49c0095111fc96b4b8dd7f4d269aba9473 Only port cmdexpand.c and test_cmdline.vim changes. Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_cmdline.vim | 91 ++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 34 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index b9f32b2db9..12a9b799c2 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -2299,39 +2299,41 @@ func Test_wildmenu_pum() set shm+=I set noruler set noshowcmd + + func CmdCompl(a, b, c) + return repeat(['aaaa'], 120) + endfunc + command -nargs=* -complete=customlist,CmdCompl Tcmd [CODE] call writefile(commands, 'Xtest') let buf = RunVimInTerminal('-S Xtest', #{rows: 10}) call term_sendkeys(buf, ":sign \") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_01', {}) + " going down the popup menu using call term_sendkeys(buf, "\\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_02', {}) + " going down the popup menu using call term_sendkeys(buf, "\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_03', {}) + " going up the popup menu using call term_sendkeys(buf, "\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_04', {}) + " going up the popup menu using call term_sendkeys(buf, "\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_05', {}) " pressing should end completion and go back to the original match call term_sendkeys(buf, "\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_06', {}) " pressing should select the current match and end completion call term_sendkeys(buf, "\\\\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_07', {}) " With 'wildmode' set to 'longest,full', completing a match should display @@ -2339,31 +2341,25 @@ func Test_wildmenu_pum() call term_sendkeys(buf, ":\set wildmode=longest,full\") call TermWait(buf) call term_sendkeys(buf, ":sign u\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_08', {}) " pressing should display the wildmenu call term_sendkeys(buf, "\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_09', {}) " pressing second time should select the next entry in the menu call term_sendkeys(buf, "\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_10', {}) call term_sendkeys(buf, ":\set wildmode=full\") - " " showing popup menu in different columns in the cmdline + " showing popup menu in different columns in the cmdline call term_sendkeys(buf, ":sign define \") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_11', {}) call term_sendkeys(buf, " \") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_12', {}) call term_sendkeys(buf, " \") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_13', {}) " Directory name completion @@ -2373,95 +2369,77 @@ func Test_wildmenu_pum() call writefile([], 'Xdir/XdirA/XdirB/XfileC') call term_sendkeys(buf, "\e Xdi\\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_14', {}) " Pressing on a directory name should go into that directory call term_sendkeys(buf, "\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_15', {}) " Pressing on a directory name should go to the parent directory call term_sendkeys(buf, "\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_16', {}) " Pressing when the popup menu is displayed should list all the - " matches and remove the popup menu + " matches but the popup menu should still remain call term_sendkeys(buf, "\sign \\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_17', {}) " Pressing when the popup menu is displayed should remove the popup " menu call term_sendkeys(buf, "\sign \\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_18', {}) " Pressing should open the popup menu with the last entry selected call term_sendkeys(buf, "\\:sign \\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_19', {}) " Pressing should close the popup menu and cancel the cmd line call term_sendkeys(buf, "\\:sign \\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_20', {}) " Typing a character when the popup is open, should close the popup call term_sendkeys(buf, ":sign \x") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_21', {}) " When the popup is open, entering the cmdline window should close the popup call term_sendkeys(buf, "\sign \\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_22', {}) call term_sendkeys(buf, ":q\") " After the last popup menu item, should show the original string call term_sendkeys(buf, ":sign u\\\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_23', {}) " Use the popup menu for the command name call term_sendkeys(buf, "\bu\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_24', {}) " Pressing the left arrow should remove the popup menu call term_sendkeys(buf, "\\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_25', {}) " Pressing should remove the popup menu and erase the last character call term_sendkeys(buf, "\\sign \\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_26', {}) " Pressing should remove the popup menu and erase the previous word call term_sendkeys(buf, "\\sign \\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_27', {}) " Pressing should remove the popup menu and erase the entire line call term_sendkeys(buf, "\\sign \\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_28', {}) " Using to cancel the popup menu and then pressing should recall " the cmdline from history call term_sendkeys(buf, "sign xyz\:sign \\\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_29', {}) " Check "list" still works call term_sendkeys(buf, "\set wildmode=longest,list\") call term_sendkeys(buf, ":cn\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_30', {}) call term_sendkeys(buf, "s") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_31', {}) " Tests a directory name contained full-width characters. @@ -2472,15 +2450,60 @@ func Test_wildmenu_pum() call term_sendkeys(buf, "\set wildmode&\") call term_sendkeys(buf, ":\e Xdir/あいう/\") - call TermWait(buf) call VerifyScreenDump(buf, 'Test_wildmenu_pum_32', {}) + " Pressing when the popup menu is displayed should list all the + " matches and pressing a key after that should remove the popup menu + call term_sendkeys(buf, "\set wildmode=full\") + call term_sendkeys(buf, ":sign \\x") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_33', {}) + + " Pressing when the popup menu is displayed should list all the + " matches and pressing after that should move the cursor + call term_sendkeys(buf, "\abc\") + call term_sendkeys(buf, ":sign \\\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_34', {}) + + " When displays a lot of matches (screen scrolls), all the matches + " should be displayed correctly on the screen. + call term_sendkeys(buf, "\\Tcmd \\\\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_35', {}) + + " After using to expand all the filename matches, pressing + " should not open the popup menu again. + call term_sendkeys(buf, "\\:cd Xdir/XdirA\") + call term_sendkeys(buf, ":e \\\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_36', {}) + call term_sendkeys(buf, "\\:cd -\") + + " After using to expand all the matches, pressing used to + " crash Vim + call term_sendkeys(buf, ":sign \\\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_37', {}) + call term_sendkeys(buf, "\\") call StopVimInTerminal(buf) call delete('Xtest') call delete('Xdir', 'rf') endfunc +" Test for wildmenumode() with the cmdline popup menu +func Test_wildmenumode_with_pum() + set wildmenu + set wildoptions=pum + cnoremap wildmenumode() + call feedkeys(":sign \\\\\"\", 'xt') + call assert_equal('"sign define10', @:) + call feedkeys(":sign \\\\\"\", 'xt') + call assert_equal('"sign define jump list place undefine unplace0', @:) + call feedkeys(":sign \\\\\"\", 'xt') + call assert_equal('"sign 0', @:) + call feedkeys(":sign \\\\\"\", 'xt') + call assert_equal('"sign define0', @:) + set nowildmenu wildoptions& + cunmap +endfunc + func Test_wildmenu_pum_clear_entries() CheckRunVimInTerminal -- cgit