]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu v8.2.4339
authorYegappan Lakshmanan <yegappan@yahoo.com>
Thu, 10 Feb 2022 19:52:10 +0000 (19:52 +0000)
committerBram Moolenaar <Bram@vim.org>
Thu, 10 Feb 2022 19:52:10 +0000 (19:52 +0000)
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 #9735)

22 files changed:
src/cmdexpand.c
src/ex_getln.c
src/popupmenu.c
src/testdir/dumps/Test_wildmenu_pum_33.dump [new file with mode: 0644]
src/testdir/dumps/Test_wildmenu_pum_34.dump [new file with mode: 0644]
src/testdir/dumps/Test_wildmenu_pum_35.dump [new file with mode: 0644]
src/testdir/dumps/Test_wildmenu_pum_36.dump [new file with mode: 0644]
src/testdir/dumps/Test_wildmenu_pum_37.dump [new file with mode: 0644]
src/testdir/screendump.vim
src/testdir/test_bufline.vim
src/testdir/test_cmdline.vim
src/testdir/test_conceal.vim
src/testdir/test_cursorline.vim
src/testdir/test_diffmode.vim
src/testdir/test_display.vim
src/testdir/test_highlight.vim
src/testdir/test_match.vim
src/testdir/test_popup.vim
src/testdir/test_search_stat.vim
src/testdir/test_terminal.vim
src/testdir/test_textprop.vim
src/version.c

index 2463ed53e33410ac4903ef528a0baa0277e90b4c..280bf8334873894f6ca23b7cd5b715b6d44b03eb 100644 (file)
@@ -37,6 +37,8 @@ static int compl_startcol;
 static int compl_selected;
 #endif
 
+#define SHOW_FILE_TEXT(m) (showtail ? sm_gettail(files_found[m]) : files_found[m])
+
     static int
 sort_func_compare(const void *s1, const void *s2)
 {
@@ -256,6 +258,54 @@ nextwild(
 }
 
 #if defined(FEAT_WILDMENU) || defined(PROTO)
+
+/*
+ * Create and display a cmdline completion popup menu with items from
+ * 'files_found'.
+ */
+    static int
+cmdline_pum_create(
+       cmdline_info_T  *ccline,
+       expand_T        *xp,
+       char_u          **files_found,
+       int             num_files,
+       int             showtail)
+{
+    int                i;
+    int                columns;
+
+    // Add all the completion matches
+    compl_match_arraysize = num_files;
+    compl_match_array = ALLOC_MULT(pumitem_T, compl_match_arraysize);
+    for (i = 0; i < num_files; i++)
+    {
+       compl_match_array[i].pum_text = SHOW_FILE_TEXT(i);
+       compl_match_array[i].pum_info = NULL;
+       compl_match_array[i].pum_extra = NULL;
+       compl_match_array[i].pum_kind = NULL;
+    }
+
+    // Compute the popup menu starting column
+    compl_startcol = vim_strsize(ccline->cmdbuff) + 1;
+    columns = vim_strsize(xp->xp_pattern);
+    if (showtail)
+    {
+       columns += vim_strsize(sm_gettail(files_found[0]));
+       columns -= vim_strsize(files_found[0]);
+    }
+    if (columns >= compl_startcol)
+       compl_startcol = 0;
+    else
+       compl_startcol -= columns;
+
+    // no default selection
+    compl_selected = -1;
+
+    cmdline_pum_display();
+
+    return EXPAND_OK;
+}
+
 /*
  * Display the cmdline completion matches in a popup menu
  */
@@ -264,13 +314,17 @@ void cmdline_pum_display(void)
     pum_display(compl_match_array, compl_match_arraysize, compl_selected);
 }
 
+/*
+ * Returns TRUE if the cmdline completion popup menu is being displayed.
+ */
 int cmdline_pum_active(void)
 {
     return p_wmnu && pum_visible() && compl_match_array != NULL;
 }
 
 /*
- * Remove the cmdline completion popup menu
+ * Remove the cmdline completion popup menu (if present), free the list of
+ * items and refresh the screen.
  */
 void cmdline_pum_remove(void)
 {
@@ -285,6 +339,10 @@ void cmdline_pum_cleanup(cmdline_info_T *cclp)
     wildmenu_cleanup(cclp);
 }
 
+/*
+ * Returns the starting column number to use for the cmdline completion popup
+ * menu.
+ */
 int cmdline_compl_startcol(void)
 {
     return compl_startcol;
@@ -581,7 +639,6 @@ ExpandCleanup(expand_T *xp)
 showmatches(expand_T *xp, int wildmenu UNUSED)
 {
     cmdline_info_T     *ccline = get_cmdline_info();
-#define L_SHOWFILE(m) (showtail ? sm_gettail(files_found[m]) : files_found[m])
     int                num_files;
     char_u     **files_found;
     int                i, j, k;
@@ -612,31 +669,8 @@ showmatches(expand_T *xp, int wildmenu UNUSED)
 
 #ifdef FEAT_WILDMENU
     if (wildmenu && vim_strchr(p_wop, WOP_PUM) != NULL)
-    {
-       compl_match_arraysize = num_files;
-       compl_match_array = ALLOC_MULT(pumitem_T, compl_match_arraysize);
-       for (i = 0; i < num_files; i++)
-       {
-           compl_match_array[i].pum_text = L_SHOWFILE(i);
-           compl_match_array[i].pum_info = NULL;
-           compl_match_array[i].pum_extra = NULL;
-           compl_match_array[i].pum_kind = NULL;
-       }
-       compl_startcol = vim_strsize(ccline->cmdbuff) + 1;
-       columns = vim_strsize(xp->xp_pattern);
-       if (showtail)
-       {
-           columns += vim_strsize(sm_gettail(files_found[0]));
-           columns -= vim_strsize(files_found[0]);
-       }
-       if (columns >= compl_startcol)
-           compl_startcol = 0;
-       else
-           compl_startcol -= columns;
-       compl_selected = -1;
-       cmdline_pum_display();
-       return EXPAND_OK;
-    }
+       // cmdline completion popup menu (with wildoptions=pum)
+       return cmdline_pum_create(ccline, xp, files_found, num_files, showtail);
 #endif
 
 #ifdef FEAT_WILDMENU
@@ -674,7 +708,7 @@ showmatches(expand_T *xp, int wildmenu UNUSED)
                j = vim_strsize(NameBuff);
            }
            else
-               j = vim_strsize(L_SHOWFILE(i));
+               j = vim_strsize(SHOW_FILE_TEXT(i));
            if (j > maxlen)
                maxlen = j;
        }
@@ -746,7 +780,7 @@ showmatches(expand_T *xp, int wildmenu UNUSED)
                        // Expansion was done here, file names are literal.
                        j = mch_isdir(files_found[k]);
                    if (showtail)
-                       p = L_SHOWFILE(k);
+                       p = SHOW_FILE_TEXT(k);
                    else
                    {
                        home_replace(NULL, files_found[k], NameBuff, MAXPATHL,
@@ -757,7 +791,7 @@ showmatches(expand_T *xp, int wildmenu UNUSED)
                else
                {
                    j = FALSE;
-                   p = L_SHOWFILE(k);
+                   p = SHOW_FILE_TEXT(k);
                }
                lastlen = msg_outtrans_attr(p, j ? attr : 0);
            }
@@ -2726,18 +2760,21 @@ wildmenu_translate_key(
     int c = key;
 
 #ifdef FEAT_WILDMENU
-    if (p_wmnu && cmdline_pum_active())
-    {
-       // When the popup menu is used, Up/Down keys go to the previous and
-       // next items in the menu and Left/Right keys go up/down a directory.
-       if (c == K_UP)
-           c = K_LEFT;
-       else if (c == K_DOWN)
-           c = K_RIGHT;
-       else if (c == K_LEFT)
-           c = K_UP;
-       else if (c == K_RIGHT)
-           c = K_DOWN;
+    if (cmdline_pum_active())
+    {
+       // When the popup menu is used for cmdline completion:
+       //   Up   : go to the previous item in the menu
+       //   Down : go to the next item in the menu
+       //   Left : go to the parent directory
+       //   Right: list the files in the selected directory
+       switch (c)
+       {
+           case K_UP:    c = K_LEFT; break;
+           case K_DOWN:  c = K_RIGHT; break;
+           case K_LEFT:  c = K_UP; break;
+           case K_RIGHT: c = K_DOWN; break;
+           default:      break;
+       }
     }
 #endif
 
index 63f1c5dcbfbef698aa9bf4230271f4eca35e3b40..f9b5b604f1853d781d20d40ffdfa0d69272857f1 100644 (file)
@@ -1860,6 +1860,9 @@ getcmdline_int(
 
        if (cmdline_pum_active())
        {
+           // Ctrl-Y: Accept the current selection and close the popup menu.
+           // Ctrl-E: cancel the cmdline popup menu and return the original
+           // text.
            if (c == Ctrl_E || c == Ctrl_Y)
            {
                int     wild_type;
@@ -1869,16 +1872,13 @@ getcmdline_int(
                if (nextwild(&xpc, wild_type, WILD_NO_BEEP,
                                                        firstc != '@') == FAIL)
                    break;
-               cmdline_pum_cleanup(&ccline);
-               xpc.xp_context = EXPAND_NOTHING;
-               goto cmdline_changed;
+               c = Ctrl_E;
            }
        }
 #endif
 
        // free expanded names when finished walking through matches
-       if (xpc.xp_numfiles != -1
-               && !(c == p_wc && KeyTyped) && c != p_wcm
+       if (!(c == p_wc && KeyTyped) && c != p_wcm
                && c != Ctrl_N && c != Ctrl_P && c != Ctrl_A
                && c != Ctrl_L)
        {
@@ -1886,7 +1886,8 @@ getcmdline_int(
            if (cmdline_pum_active())
                cmdline_pum_remove();
 #endif
-           (void)ExpandOne(&xpc, NULL, NULL, 0, WILD_FREE);
+           if (xpc.xp_numfiles != -1)
+               (void)ExpandOne(&xpc, NULL, NULL, 0, WILD_FREE);
            did_wild_list = FALSE;
 #ifdef FEAT_WILDMENU
            if (!p_wmnu || (c != K_UP && c != K_DOWN))
@@ -1982,13 +1983,16 @@ getcmdline_int(
        {
            if (nextwild(&xpc, WILD_EXPAND_KEEP, 0, firstc != '@') == OK)
            {
+               if (xpc.xp_numfiles > 1)
+               {
 #ifdef FEAT_WILDMENU
-               // Trigger the popup menu when wildoptions=pum
-               showmatches(&xpc,
-                       p_wmnu && ((wim_flags[wim_index] & WIM_LIST) == 0));
+                   // Trigger the popup menu when wildoptions=pum
+                   showmatches(&xpc, p_wmnu
+                           && ((wim_flags[wim_index] & WIM_LIST) == 0));
 #else
-               (void)showmatches(&xpc, FALSE);
+                   (void)showmatches(&xpc, FALSE);
 #endif
+               }
                if (nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK
                        && nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK)
                    goto cmdline_changed;
@@ -2259,15 +2263,16 @@ getcmdline_int(
                goto cmdline_not_changed;
 
        case Ctrl_A:        // all matches
-               if (nextwild(&xpc, WILD_ALL, 0, firstc != '@') == FAIL)
-                   break;
 #ifdef FEAT_WILDMENU
                if (cmdline_pum_active())
-               {
+                   // As Ctrl-A completes all the matches, close the popup
+                   // menu (if present)
                    cmdline_pum_cleanup(&ccline);
-                   xpc.xp_context = EXPAND_NOTHING;
-               }
 #endif
+               if (nextwild(&xpc, WILD_ALL, 0, firstc != '@') == FAIL)
+                   break;
+               xpc.xp_context = EXPAND_NOTHING;
+               did_wild_list = FALSE;
                goto cmdline_changed;
 
        case Ctrl_L:
index cf2f2eff97e0087e11227a74327eebc55984fdcc..18f24803358bfdff1774f8c6ddf4bf7367cd293b 100644 (file)
@@ -117,6 +117,7 @@ pum_display(
        // can decide when to reposition the popup menu.
        pum_window = curwin;
        if (State == CMDLINE)
+           // cmdline completion popup menu
            pum_win_row = cmdline_row;
        else
            pum_win_row = curwin->w_wrow + W_WINROW(curwin);
@@ -220,6 +221,7 @@ pum_display(
        // Calculate column
 #ifdef FEAT_WILDMENU
        if (State == CMDLINE)
+           // cmdline completion popup menu
            cursor_col = cmdline_compl_startcol();
        else
 #endif
diff --git a/src/testdir/dumps/Test_wildmenu_pum_33.dump b/src/testdir/dumps/Test_wildmenu_pum_33.dump
new file mode 100644 (file)
index 0000000..3955edb
--- /dev/null
@@ -0,0 +1,10 @@
+| +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|:+0#0000000&|s|i|g|n| |d|e|f|i|n|e| |j|u|m|p| |l|i|s|t| |p|l|a|c|e| |u|n|d|e|f|i|n|e| |u|n|p|l|a|c|e|x> @28
diff --git a/src/testdir/dumps/Test_wildmenu_pum_34.dump b/src/testdir/dumps/Test_wildmenu_pum_34.dump
new file mode 100644 (file)
index 0000000..e28b913
--- /dev/null
@@ -0,0 +1,10 @@
+| +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|:+0#0000000&|s|i|g|n| |d|e|f|i|n|e| |j|u|m|p| |l|i|s|t| |p|l|a|c|e| |u|n|d|e|f|i|n|e| |u|n|p|l|a|c>e| @29
diff --git a/src/testdir/dumps/Test_wildmenu_pum_35.dump b/src/testdir/dumps/Test_wildmenu_pum_35.dump
new file mode 100644 (file)
index 0000000..3fbd30a
--- /dev/null
@@ -0,0 +1,10 @@
+|~+0#4040ff13#ffffff0| @73
+|:+0#0000000&|T|c|m|d| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3
+| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3
+| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3
+| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3
+| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3
+| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3
+| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3
+| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3| |a@3
+| |a@1>a@1| @69
diff --git a/src/testdir/dumps/Test_wildmenu_pum_36.dump b/src/testdir/dumps/Test_wildmenu_pum_36.dump
new file mode 100644 (file)
index 0000000..9d7b6b0
--- /dev/null
@@ -0,0 +1,10 @@
+| +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|:+0#0000000&|e| |X|d|i|r|B|/| |X|f|i|l|e|B> @58
diff --git a/src/testdir/dumps/Test_wildmenu_pum_37.dump b/src/testdir/dumps/Test_wildmenu_pum_37.dump
new file mode 100644 (file)
index 0000000..5eef94d
--- /dev/null
@@ -0,0 +1,10 @@
+| +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|:+0#0000000&|s|i|g|n| |d|e|f|i|n|e| |j|u|m|p| |l|i|s|t| |p|l|a|c|e| |u|n|d|e|f|i|n|e| |u|n|p|l|a|c|e> @29
index 8ea708a39fb5ddfa062f7e640cd3f705a99f4289..8fc496d1e1136d87c9d4702975d95ec87e72cc1e 100644 (file)
@@ -27,6 +27,9 @@ func VerifyScreenDump(buf, filename, options, ...)
   " Starting a terminal to make a screendump is always considered flaky.
   let g:test_is_flaky = 1
 
+  " wait for the pending updates to be handled.
+  call TermWait(a:buf)
+
   " Redraw to execute the code that updates the screen.  Otherwise we get the
   " text and attributes only from the internal buffer.
   redraw
index 04653bacb84e0f50d12c33bd4488b410d2851319..3acf7c96cd872447b996ed9688ee872c49ff030f 100644 (file)
@@ -216,7 +216,6 @@ func Test_appendbufline_redraw()
   END
   call writefile(lines, 'XscriptMatchCommon')
   let buf = RunVimInTerminal('-S XscriptMatchCommon', #{rows: 10})
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_appendbufline_1', {})
 
   call StopVimInTerminal(buf)
index c40d653d3c294dd4c280de83748384bed8aaaacf..8c5928faacf4c770b4dd4d06d44966b260c75d14 100644 (file)
@@ -91,7 +91,9 @@ func Test_complete_wildmenu()
 
   cnoremap <expr> <F2> wildmenumode()
   call feedkeys(":cd Xdir\<Tab>\<F2>\<C-B>\"\<CR>", 'tx')
-  call assert_equal('"cd Xdir1/1', @:)
+  call assert_equal('"cd Xdir1/0', @:)
+  call feedkeys(":e Xdir1/\<Tab>\<F2>\<C-B>\"\<CR>", 'tx')
+  call assert_equal('"e Xdir1/Xdir2/1', @:)
   cunmap <F2>
 
   " cleanup
@@ -1976,39 +1978,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 \<Tab>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_01', {})
 
+  " going down the popup menu using <Down>
   call term_sendkeys(buf, "\<Down>\<Down>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_02', {})
 
+  " going down the popup menu using <C-N>
   call term_sendkeys(buf, "\<C-N>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_03', {})
 
+  " going up the popup menu using <C-P>
   call term_sendkeys(buf, "\<C-P>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_04', {})
 
+  " going up the popup menu using <Up>
   call term_sendkeys(buf, "\<Up>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_05', {})
 
   " pressing <C-E> should end completion and go back to the original match
   call term_sendkeys(buf, "\<C-E>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_06', {})
 
   " pressing <C-Y> should select the current match and end completion
   call term_sendkeys(buf, "\<Tab>\<C-P>\<C-P>\<C-Y>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_07', {})
 
   " With 'wildmode' set to 'longest,full', completing a match should display
@@ -2016,31 +2020,25 @@ func Test_wildmenu_pum()
   call term_sendkeys(buf, ":\<C-U>set wildmode=longest,full\<CR>")
   call TermWait(buf)
   call term_sendkeys(buf, ":sign u\<Tab>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_08', {})
 
   " pressing <Tab> should display the wildmenu
   call term_sendkeys(buf, "\<Tab>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_09', {})
 
   " pressing <Tab> second time should select the next entry in the menu
   call term_sendkeys(buf, "\<Tab>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_10', {})
 
   call term_sendkeys(buf, ":\<C-U>set wildmode=full\<CR>")
-  " showing popup menu in different columns in the cmdline
+  " showing popup menu in different columns in the cmdline
   call term_sendkeys(buf, ":sign define \<Tab>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_11', {})
 
   call term_sendkeys(buf, " \<Tab>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_12', {})
 
   call term_sendkeys(buf, " \<Tab>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_13', {})
 
   " Directory name completion
@@ -2050,95 +2048,77 @@ func Test_wildmenu_pum()
   call writefile([], 'Xdir/XdirA/XdirB/XfileC')
 
   call term_sendkeys(buf, "\<C-U>e Xdi\<Tab>\<Tab>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_14', {})
 
   " Pressing <Right> on a directory name should go into that directory
   call term_sendkeys(buf, "\<Right>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_15', {})
 
   " Pressing <Left> on a directory name should go to the parent directory
   call term_sendkeys(buf, "\<Left>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_16', {})
 
   " Pressing <C-A> 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, "\<C-U>sign \<Tab>\<C-A>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_17', {})
 
   " Pressing <C-D> when the popup menu is displayed should remove the popup
   " menu
   call term_sendkeys(buf, "\<C-U>sign \<Tab>\<C-D>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_18', {})
 
   " Pressing <S-Tab> should open the popup menu with the last entry selected
   call term_sendkeys(buf, "\<C-U>\<CR>:sign \<S-Tab>\<C-P>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_19', {})
 
   " Pressing <Esc> should close the popup menu and cancel the cmd line
   call term_sendkeys(buf, "\<C-U>\<CR>:sign \<Tab>\<Esc>")
-  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 \<Tab>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, "\<C-U>sign \<Tab>\<C-F>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_22', {})
   call term_sendkeys(buf, ":q\<CR>")
 
   " After the last popup menu item, <C-N> should show the original string
   call term_sendkeys(buf, ":sign u\<Tab>\<C-N>\<C-N>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_23', {})
 
   " Use the popup menu for the command name
   call term_sendkeys(buf, "\<C-U>bu\<Tab>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_24', {})
 
   " Pressing the left arrow should remove the popup menu
   call term_sendkeys(buf, "\<Left>\<Left>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_25', {})
 
   " Pressing <BS> should remove the popup menu and erase the last character
   call term_sendkeys(buf, "\<C-E>\<C-U>sign \<Tab>\<BS>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_26', {})
 
   " Pressing <C-W> should remove the popup menu and erase the previous word
   call term_sendkeys(buf, "\<C-E>\<C-U>sign \<Tab>\<C-W>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_27', {})
 
   " Pressing <C-U> should remove the popup menu and erase the entire line
   call term_sendkeys(buf, "\<C-E>\<C-U>sign \<Tab>\<C-U>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_28', {})
 
   " Using <C-E> to cancel the popup menu and then pressing <Up> should recall
   " the cmdline from history
   call term_sendkeys(buf, "sign xyz\<Esc>:sign \<Tab>\<C-E>\<Up>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_29', {})
 
   " Check "list" still works
   call term_sendkeys(buf, "\<C-U>set wildmode=longest,list\<CR>")
   call term_sendkeys(buf, ":cn\<Tab>")
-  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.
@@ -2149,13 +2129,58 @@ func Test_wildmenu_pum()
 
   call term_sendkeys(buf, "\<C-U>set wildmode&\<CR>")
   call term_sendkeys(buf, ":\<C-U>e Xdir/あいう/\<Tab>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_wildmenu_pum_32', {})
 
+  " Pressing <C-A> 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, "\<C-U>set wildmode=full\<CR>")
+  call term_sendkeys(buf, ":sign \<Tab>\<C-A>x")
+  call VerifyScreenDump(buf, 'Test_wildmenu_pum_33', {})
+
+  " Pressing <C-A> when the popup menu is displayed should list all the
+  " matches and pressing <Left> after that should move the cursor
+  call term_sendkeys(buf, "\<C-U>abc\<Esc>")
+  call term_sendkeys(buf, ":sign \<Tab>\<C-A>\<Left>")
+  call VerifyScreenDump(buf, 'Test_wildmenu_pum_34', {})
+
+  " When <C-A> displays a lot of matches (screen scrolls), all the matches
+  " should be displayed correctly on the screen.
+  call term_sendkeys(buf, "\<End>\<C-U>Tcmd \<Tab>\<C-A>\<Left>\<Left>")
+  call VerifyScreenDump(buf, 'Test_wildmenu_pum_35', {})
+
+  " After using <C-A> to expand all the filename matches, pressing <Up>
+  " should not open the popup menu again.
+  call term_sendkeys(buf, "\<C-E>\<C-U>:cd Xdir/XdirA\<CR>")
+  call term_sendkeys(buf, ":e \<Tab>\<C-A>\<Up>")
+  call VerifyScreenDump(buf, 'Test_wildmenu_pum_36', {})
+  call term_sendkeys(buf, "\<C-E>\<C-U>:cd -\<CR>")
+
+  " After using <C-A> to expand all the matches, pressing <S-Tab> used to
+  " crash Vim
+  call term_sendkeys(buf, ":sign \<Tab>\<C-A>\<S-Tab>")
+  call VerifyScreenDump(buf, 'Test_wildmenu_pum_37', {})
+
   call term_sendkeys(buf, "\<C-U>\<CR>")
   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 <expr> <F2> wildmenumode()
+  call feedkeys(":sign \<Tab>\<F2>\<F2>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"sign define10', @:)
+  call feedkeys(":sign \<Tab>\<C-A>\<F2>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"sign define jump list place undefine unplace0', @:)
+  call feedkeys(":sign \<Tab>\<C-E>\<F2>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"sign 0', @:)
+  call feedkeys(":sign \<Tab>\<C-Y>\<F2>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"sign define0', @:)
+  set nowildmenu wildoptions&
+  cunmap <F2>
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index cf4194d71ccd46723373bbb585a033d24f825471..ad11eb721eb1ad5678a51d6e053f6f02dbbbd124 100644 (file)
@@ -154,7 +154,6 @@ func Test_conceal_resize_term()
   call VerifyScreenDump(buf, 'Test_conceal_resize_01', {})
 
   call win_execute(buf->win_findbuf()[0], 'wincmd +')
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_conceal_resize_02', {})
 
   " clean up
index d17a424d9869e5c114bbcba7e953648705ea92a8..245048b93359f654df98701752ae60e2e8456dd0 100644 (file)
@@ -136,41 +136,30 @@ func Test_cursorline_screenline()
   call writefile(lines, filename)
   " basic test
   let buf = RunVimInTerminal('-S '. filename, #{rows: 20})
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_'. filename. '_1', {})
   call term_sendkeys(buf, "fagj")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_'. filename. '_2', {})
   call term_sendkeys(buf, "gj")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_'. filename. '_3', {})
   call term_sendkeys(buf, "gj")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_'. filename. '_4', {})
   call term_sendkeys(buf, "gj")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_'. filename. '_5', {})
   call term_sendkeys(buf, "gj")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_'. filename. '_6', {})
   " test with set list and cursorlineopt containing number
   call term_sendkeys(buf, "gg0")
   call term_sendkeys(buf, ":set list cursorlineopt+=number listchars=space:-\<cr>")
   call VerifyScreenDump(buf, 'Test_'. filename. '_7', {})
   call term_sendkeys(buf, "fagj")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_'. filename. '_8', {})
   call term_sendkeys(buf, "gj")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_'. filename. '_9', {})
   call term_sendkeys(buf, "gj")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_'. filename. '_10', {})
   call term_sendkeys(buf, "gj")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_'. filename. '_11', {})
   call term_sendkeys(buf, "gj")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_'. filename. '_12', {})
   if exists("+foldcolumn") && exists("+signcolumn") && exists("+breakindent")
     " test with set foldcolumn signcoloumn and breakindent
@@ -178,19 +167,14 @@ func Test_cursorline_screenline()
     call term_sendkeys(buf, ":set breakindent foldcolumn=2 signcolumn=yes\<cr>")
     call VerifyScreenDump(buf, 'Test_'. filename. '_13', {})
     call term_sendkeys(buf, "fagj")
-    call TermWait(buf)
     call VerifyScreenDump(buf, 'Test_'. filename. '_14', {})
     call term_sendkeys(buf, "gj")
-    call TermWait(buf)
     call VerifyScreenDump(buf, 'Test_'. filename. '_15', {})
     call term_sendkeys(buf, "gj")
-    call TermWait(buf)
     call VerifyScreenDump(buf, 'Test_'. filename. '_16', {})
     call term_sendkeys(buf, "gj")
-    call TermWait(buf)
     call VerifyScreenDump(buf, 'Test_'. filename. '_17', {})
     call term_sendkeys(buf, "gj")
-    call TermWait(buf)
     call VerifyScreenDump(buf, 'Test_'. filename. '_18', {})
     call term_sendkeys(buf, ":set breakindent& foldcolumn& signcolumn&\<cr>")
   endif
@@ -200,19 +184,14 @@ func Test_cursorline_screenline()
   call term_sendkeys(buf, ":set nonumber\<cr>")
   call VerifyScreenDump(buf, 'Test_'. filename. '_19', {})
   call term_sendkeys(buf, "fagj")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_'. filename. '_20', {})
   call term_sendkeys(buf, "gj")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_'. filename. '_21', {})
   call term_sendkeys(buf, "gj")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_'. filename. '_22', {})
   call term_sendkeys(buf, "gj")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_'. filename. '_23', {})
   call term_sendkeys(buf, "gj")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_'. filename. '_24', {})
   call term_sendkeys(buf, ":set list& cursorlineopt& listchars&\<cr>")
 
index ea217d94e262aef32abe6af60873ab351aca9658..c626023b47b60fd5d8a6429f8fb62294ec8a8a0a 100644 (file)
@@ -851,7 +851,6 @@ func VerifyInternal(buf, dumpfile, extra)
   call term_sendkeys(a:buf, ":diffupdate!\<CR>")
   " trailing : for leaving the cursor on the command line
   call term_sendkeys(a:buf, ":set diffopt=internal,filler" . a:extra . "\<CR>:")
-  call TermWait(a:buf)
   call VerifyScreenDump(a:buf, a:dumpfile, {})
 endfunc
 
index c14dc7812fa1be94ac4e963cb6ae552bdc89f582..a2e6fafd8802daf02651d28053dfefa12496ef05 100644 (file)
@@ -175,7 +175,6 @@ func Test_scroll_CursorLineNr_update()
   call writefile(lines, filename)
   let buf = RunVimInTerminal('-S '.filename, #{rows: 5, cols: 50})
   call term_sendkeys(buf, "k")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_winline_rnu', {})
 
   " clean up
index 9870b2e6c6b58dcbc9998ce6d486ec2a8ff21e92..8b3bcdc3961b60aae4e4256b640ef7238d28a1d7 100644 (file)
@@ -662,7 +662,6 @@ func Test_colorcolumn()
   call writefile(lines, 'Xtest_colorcolumn')
   let buf = RunVimInTerminal('-S Xtest_colorcolumn', {'rows': 10})
   call term_sendkeys(buf, ":\<CR>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_colorcolumn_1', {})
 
   " clean up
@@ -680,7 +679,6 @@ func Test_colorcolumn_bri()
   call writefile(lines, 'Xtest_colorcolumn_bri')
   let buf = RunVimInTerminal('-S Xtest_colorcolumn_bri', {'rows': 10,'columns': 40})
   call term_sendkeys(buf, ":set co=40 linebreak bri briopt=shift:2 cc=40,41,43\<CR>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_colorcolumn_2', {})
 
   " clean up
@@ -698,7 +696,6 @@ func Test_colorcolumn_sbr()
   call writefile(lines, 'Xtest_colorcolumn_srb')
   let buf = RunVimInTerminal('-S Xtest_colorcolumn_srb', {'rows': 10,'columns': 40})
   call term_sendkeys(buf, ":set co=40 showbreak=+++>\\  cc=40,41,43\<CR>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_colorcolumn_3', {})
 
   " clean up
index a912b78a126150000501ec28c8f2c439535cab9d..45f83897577f2aa28f7809e0a64fed449c415e3b 100644 (file)
@@ -359,7 +359,6 @@ func Test_match_in_linebreak()
   END
   call writefile(lines, 'XscriptMatchLinebreak')
   let buf = RunVimInTerminal('-S XscriptMatchLinebreak', #{rows: 10})
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_match_linebreak', {})
 
   call StopVimInTerminal(buf)
@@ -376,7 +375,6 @@ func Test_match_with_incsearch()
   END
   call writefile(lines, 'XmatchWithIncsearch')
   let buf = RunVimInTerminal('-S XmatchWithIncsearch', #{rows: 6})
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_match_with_incsearch_1', {})
 
   call term_sendkeys(buf, ":s/0")
@@ -417,7 +415,6 @@ func Test_match_tab_with_linebreak()
   END
   call writefile(lines, 'XscriptMatchTabLinebreak')
   let buf = RunVimInTerminal('-S XscriptMatchTabLinebreak', #{rows: 10})
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_match_tab_linebreak', {})
 
   call StopVimInTerminal(buf)
index 2f29163edebc8121fa45c7d1013400c99eefc27d..5d04583717e89541aae8097ab6c288f5c31a94bb 100644 (file)
@@ -1164,7 +1164,6 @@ func Test_pum_rightleft()
   let buf = RunVimInTerminal('--cmd "set rightleft" Xtest1', {})
   call term_wait(buf)
   call term_sendkeys(buf, "Go\<C-P>")
-  call term_wait(buf)
   call VerifyScreenDump(buf, 'Test_pum_rightleft_01', {'rows': 8})
   call term_sendkeys(buf, "\<C-P>\<C-Y>")
   call term_wait(buf)
@@ -1206,7 +1205,6 @@ func Test_pum_scrollbar()
   let buf = RunVimInTerminal('--cmd "set pumheight=2" Xtest1', {})
   call term_wait(buf)
   call term_sendkeys(buf, "Go\<C-P>\<C-P>\<C-P>")
-  call term_wait(buf)
   call VerifyScreenDump(buf, 'Test_pum_scrollbar_01', {'rows': 7})
   call term_sendkeys(buf, "\<C-E>\<Esc>dd")
   call term_wait(buf)
@@ -1215,7 +1213,6 @@ func Test_pum_scrollbar()
     call term_sendkeys(buf, ":set rightleft\<CR>")
     call term_wait(buf)
     call term_sendkeys(buf, "Go\<C-P>\<C-P>\<C-P>")
-    call term_wait(buf)
     call VerifyScreenDump(buf, 'Test_pum_scrollbar_02', {'rows': 7})
   endif
 
index 68fcc4911fa3871d9c715705ced0338db8a09a5f..15da1555629381d8481dd875ef4ee199c531d192 100644 (file)
@@ -312,15 +312,12 @@ func Test_search_stat_foldopen()
   call writefile(lines, 'Xsearchstat1')
 
   let buf = RunVimInTerminal('-S Xsearchstat1', #{rows: 10})
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_searchstat_3', {})
 
   call term_sendkeys(buf, "n")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_searchstat_3', {})
 
   call term_sendkeys(buf, "n")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_searchstat_3', {})
 
   call StopVimInTerminal(buf)
@@ -343,12 +340,10 @@ func! Test_search_stat_screendump()
   END
   call writefile(lines, 'Xsearchstat')
   let buf = RunVimInTerminal('-S Xsearchstat', #{rows: 10})
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_searchstat_1', {})
 
   call term_sendkeys(buf, ":nnoremap <silent> n n\<cr>")
   call term_sendkeys(buf, "gg0n")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_searchstat_2', {})
 
   call StopVimInTerminal(buf)
@@ -367,11 +362,9 @@ func Test_search_stat_then_gd()
 
   let buf = RunVimInTerminal('-S Xsearchstatgd', #{rows: 10})
   call term_sendkeys(buf, "/dog\<CR>")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_searchstatgd_1', {})
 
   call term_sendkeys(buf, "G0gD")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_searchstatgd_2', {})
 
   call StopVimInTerminal(buf)
index 4ef977bbeda69938345b9a5868fcab65c2d20bfb..233994275d76ebb93a9b79b2232ba7f6c0866e9b 100644 (file)
@@ -1137,18 +1137,15 @@ func Test_aa_terminal_focus_events()
 
   " Send a focus event to ourselves, it should be forwarded to the terminal
   call feedkeys("\<Esc>[O", "Lx!")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_terminal_focus_1', {})
 
   call feedkeys("\<Esc>[I", "Lx!")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_terminal_focus_2', {})
 
   " check that a command line being edited is redrawn in place
   call term_sendkeys(buf, ":" .. repeat('x', 80))
   call TermWait(buf)
   call feedkeys("\<Esc>[O", "Lx!")
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_terminal_focus_3', {})
   call term_sendkeys(buf, "\<Esc>")
 
index ed2856f9bf3491bc25e40ac2a001a50dc9341df0..530a25662ac2ac2fee0fccffb3d762ec23425163 100644 (file)
@@ -1626,7 +1626,6 @@ func Test_prop_in_linebreak()
   END
   call writefile(lines, 'XscriptPropLinebreak')
   let buf = RunVimInTerminal('-S XscriptPropLinebreak', #{rows: 10})
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_prop_linebreak', {})
 
   call StopVimInTerminal(buf)
@@ -1644,7 +1643,6 @@ func Test_prop_after_tab()
   END
   call writefile(lines, 'XscriptPropAfterTab')
   let buf = RunVimInTerminal('-S XscriptPropAfterTab', #{rows: 10})
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_prop_after_tab', {})
 
   call StopVimInTerminal(buf)
@@ -1662,7 +1660,6 @@ func Test_prop_after_linebreak()
   END
   call writefile(lines, 'XscriptPropAfterLinebreak')
   let buf = RunVimInTerminal('-S XscriptPropAfterLinebreak', #{rows: 10})
-  call TermWait(buf)
   call VerifyScreenDump(buf, 'Test_prop_after_linebreak', {})
 
   call StopVimInTerminal(buf)
index db2a9239211d700839e825e5c9befa3c9da411ea..6b6d3cc20131acba42b9e3dc522399f01d9efc97 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4339,
 /**/
     4338,
 /**/