To: vim_dev@googlegroups.com Subject: Patch 8.2.4579 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4579 Problem: Cannot use page-up and page-down in the command line completion popup menu. Solution: Check for to page-up and page-down keys. (Yegappan Lakshmanan, closes #9960) Files: src/cmdexpand.c, src/ex_getln.c, src/spellsuggest.c, src/vim.h, src/testdir/test_cmdline.vim, src/testdir/dumps/Test_wildmenu_pum_42.dump, src/testdir/dumps/Test_wildmenu_pum_43.dump, src/testdir/dumps/Test_wildmenu_pum_44.dump, src/testdir/dumps/Test_wildmenu_pum_45.dump, src/testdir/dumps/Test_wildmenu_pum_46.dump, src/testdir/dumps/Test_wildmenu_pum_47.dump, src/testdir/dumps/Test_wildmenu_pum_48.dump, src/testdir/dumps/Test_wildmenu_pum_49.dump, src/testdir/dumps/Test_wildmenu_pum_50.dump *** ../vim-8.2.4578/src/cmdexpand.c 2022-03-15 10:53:01.547462727 +0000 --- src/cmdexpand.c 2022-03-16 13:31:49.046634396 +0000 *************** *** 224,230 **** i = (int)(xp->xp_pattern - ccline->cmdbuff); xp->xp_pattern_len = ccline->cmdpos - i; ! if (type == WILD_NEXT || type == WILD_PREV) { // Get next/previous match for a previous expanded pattern. p2 = ExpandOne(xp, NULL, NULL, 0, type); --- 224,231 ---- i = (int)(xp->xp_pattern - ccline->cmdbuff); xp->xp_pattern_len = ccline->cmdpos - i; ! if (type == WILD_NEXT || type == WILD_PREV ! || type == WILD_PAGEUP || type == WILD_PAGEDOWN) { // Get next/previous match for a previous expanded pattern. p2 = ExpandOne(xp, NULL, NULL, 0, type); *************** *** 404,410 **** /* * Get the next or prev cmdline completion match. The index of the match is set ! * in 'p_findex' */ static char_u * get_next_or_prev_match( --- 405,411 ---- /* * Get the next or prev cmdline completion match. The index of the match is set ! * in "p_findex" */ static char_u * get_next_or_prev_match( *************** *** 414,419 **** --- 415,421 ---- char_u *orig_save) { int findex = *p_findex; + int ht; if (xp->xp_numfiles <= 0) return NULL; *************** *** 424,434 **** findex = xp->xp_numfiles; --findex; } ! else // mode == WILD_NEXT ++findex; ! // When wrapping around, return the original string, set findex to ! // -1. if (findex < 0) { if (orig_save == NULL) --- 426,475 ---- findex = xp->xp_numfiles; --findex; } ! else if (mode == WILD_NEXT) ++findex; + else if (mode == WILD_PAGEUP) + { + if (findex == 0) + // at the first entry, don't select any entries + findex = -1; + else if (findex == -1) + // no entry is selected. select the last entry + findex = xp->xp_numfiles - 1; + else + { + // go up by the pum height + ht = pum_get_height(); + if (ht > 3) + ht -= 2; + findex -= ht; + if (findex < 0) + // few entries left, select the first entry + findex = 0; + } + } + else // mode == WILD_PAGEDOWN + { + if (findex == xp->xp_numfiles - 1) + // at the last entry, don't select any entries + findex = -1; + else if (findex == -1) + // no entry is selected. select the first entry + findex = 0; + else + { + // go down by the pum height + ht = pum_get_height(); + if (ht > 3) + ht -= 2; + findex += ht; + if (findex >= xp->xp_numfiles) + // few entries left, select the last entry + findex = xp->xp_numfiles - 1; + } + } ! // When wrapping around, return the original string, set findex to -1. if (findex < 0) { if (orig_save == NULL) *************** *** 585,591 **** } /* ! * Do wildcard expansion on the string 'str'. * Chars that should not be expanded must be preceded with a backslash. * Return a pointer to allocated memory containing the new string. * Return NULL for failure. --- 626,632 ---- } /* ! * Do wildcard expansion on the string "str". * Chars that should not be expanded must be preceded with a backslash. * Return a pointer to allocated memory containing the new string. * Return NULL for failure. *************** *** 639,645 **** long_u len; // first handle the case of using an old match ! if (mode == WILD_NEXT || mode == WILD_PREV) return get_next_or_prev_match(mode, xp, &findex, orig_save); if (mode == WILD_CANCEL) --- 680,687 ---- long_u len; // first handle the case of using an old match ! if (mode == WILD_NEXT || mode == WILD_PREV ! || mode == WILD_PAGEUP || mode == WILD_PAGEDOWN) return get_next_or_prev_match(mode, xp, &findex, orig_save); if (mode == WILD_CANCEL) *** ../vim-8.2.4578/src/ex_getln.c 2022-02-25 20:57:06.519021527 +0000 --- src/ex_getln.c 2022-03-16 13:26:18.215158792 +0000 *************** *** 1757,1762 **** --- 1757,1763 ---- for (;;) { int trigger_cmdlinechanged = TRUE; + int end_wildmenu; redir_off = TRUE; // Don't redirect the typed command. // Repeated, because a ":redir" inside *************** *** 1878,1887 **** } #endif // free expanded names when finished walking through matches ! if (!(c == p_wc && KeyTyped) && c != p_wcm ! && c != Ctrl_N && c != Ctrl_P && c != Ctrl_A ! && c != Ctrl_L) { #ifdef FEAT_WILDMENU if (cmdline_pum_active()) --- 1879,1899 ---- } #endif + // The wildmenu is cleared if the pressed key is not used for + // navigating the wild menu (i.e. the key is not 'wildchar' or + // 'wildcharm' or Ctrl-N or Ctrl-P or Ctrl-A or Ctrl-L). + // If the popup menu is displayed, then PageDown and PageUp keys are + // also used to navigate the menu. + end_wildmenu = (!(c == p_wc && KeyTyped) && c != p_wcm + && c != Ctrl_N && c != Ctrl_P && c != Ctrl_A && c != Ctrl_L); + #ifdef FEAT_WILDMENU + end_wildmenu = end_wildmenu && (!cmdline_pum_active() || + (c != K_PAGEDOWN && c != K_PAGEUP + && c != K_KPAGEDOWN && c != K_KPAGEUP)); + #endif + // free expanded names when finished walking through matches ! if (end_wildmenu) { #ifdef FEAT_WILDMENU if (cmdline_pum_active()) *************** *** 2306,2317 **** case K_KPAGEUP: case K_PAGEDOWN: case K_KPAGEDOWN: ! res = cmdline_browse_history(c, firstc, &lookfor, histype, ! &hiscnt, &xpc); ! if (res == CMDLINE_CHANGED) ! goto cmdline_changed; ! else if (res == GOTO_NORMAL_MODE) ! goto returncmd; goto cmdline_not_changed; #ifdef FEAT_SEARCH_EXTRA --- 2318,2346 ---- case K_KPAGEUP: case K_PAGEDOWN: case K_KPAGEDOWN: ! #ifdef FEAT_WILDMENU ! if (cmdline_pum_active() ! && (c == K_PAGEUP || c == K_PAGEDOWN || ! c == K_KPAGEUP || c == K_KPAGEDOWN)) ! { ! // If the popup menu is displayed, then PageUp and PageDown ! // are used to scroll the menu. ! if (nextwild(&xpc, ! (c == K_PAGEUP) ? WILD_PAGEUP : WILD_PAGEDOWN, ! 0, firstc != '@') == FAIL) ! break; ! goto cmdline_not_changed; ! } ! else ! #endif ! { ! res = cmdline_browse_history(c, firstc, &lookfor, histype, ! &hiscnt, &xpc); ! if (res == CMDLINE_CHANGED) ! goto cmdline_changed; ! else if (res == GOTO_NORMAL_MODE) ! goto returncmd; ! } goto cmdline_not_changed; #ifdef FEAT_SEARCH_EXTRA *** ../vim-8.2.4578/src/spellsuggest.c 2022-03-14 19:24:41.867926390 +0000 --- src/spellsuggest.c 2022-03-16 13:26:18.215158792 +0000 *************** *** 509,515 **** // make sure we don't include the NUL at the end of the line line = ml_get_curline(); if (badlen > (int)STRLEN(line) - (int)curwin->w_cursor.col) ! badlen = STRLEN(line) - curwin->w_cursor.col; } // Find the start of the badly spelled word. else if (spell_move_to(curwin, FORWARD, TRUE, TRUE, NULL) == 0 --- 509,515 ---- // make sure we don't include the NUL at the end of the line line = ml_get_curline(); if (badlen > (int)STRLEN(line) - (int)curwin->w_cursor.col) ! badlen = (int)STRLEN(line) - (int)curwin->w_cursor.col; } // Find the start of the badly spelled word. else if (spell_move_to(curwin, FORWARD, TRUE, TRUE, NULL) == 0 *** ../vim-8.2.4578/src/vim.h 2022-03-15 19:29:26.542954696 +0000 --- src/vim.h 2022-03-16 13:26:18.215158792 +0000 *************** *** 818,823 **** --- 818,825 ---- #define WILD_ALL_KEEP 8 #define WILD_CANCEL 9 #define WILD_APPLY 10 + #define WILD_PAGEUP 11 + #define WILD_PAGEDOWN 12 #define WILD_LIST_NOTFOUND 0x01 #define WILD_HOME_REPLACE 0x02 *** ../vim-8.2.4578/src/testdir/test_cmdline.vim 2022-03-16 13:09:11.329619036 +0000 --- src/testdir/test_cmdline.vim 2022-03-16 13:26:18.215158792 +0000 *************** *** 152,157 **** --- 152,165 ---- call assert_equal('"e Xdir1/Xdir2/1', @:) cunmap + " Test for canceling the wild menu by pressing or . + " After this pressing or should not change the selection. + call feedkeys(":sign \\\\\\\"\", 'tx') + call assert_equal('"sign define', @:) + call histadd('cmd', 'TestWildMenu') + call feedkeys(":sign \\\\\\\"\", 'tx') + call assert_equal('"TestWildMenu', @:) + " cleanup %bwipe call delete('Xdir1', 'rf') *************** *** 2416,2421 **** --- 2424,2451 ---- call VerifyScreenDump(buf, 'Test_wildmenu_pum_41', {}) call term_sendkeys(buf, "\") + " Pressing should scroll the menu downward + call term_sendkeys(buf, ":sign \\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_42', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_43', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_44', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_45', {}) + call term_sendkeys(buf, "\sign \\\\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_46', {}) + + " Pressing should scroll the menu upward + call term_sendkeys(buf, "\sign \\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_47', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_48', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_49', {}) + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_pum_50', {}) + call term_sendkeys(buf, "\\") call StopVimInTerminal(buf) call delete('Xtest') *** ../vim-8.2.4578/src/testdir/dumps/Test_wildmenu_pum_42.dump 2022-03-16 13:32:52.270521972 +0000 --- src/testdir/dumps/Test_wildmenu_pum_42.dump 2022-03-16 13:26:18.215158792 +0000 *************** *** 0 **** --- 1,10 ---- + | +0&#ffffff0@74 + |~+0#4040ff13&| @73 + |~| @73 + |~| @3| +0#0000001#ffd7ff255|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|j|u|m|p| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#e0e0e08|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53 + |:+0#0000000&|s|i|g|n| |u|n|d|e|f|i|n|e> @60 *** ../vim-8.2.4578/src/testdir/dumps/Test_wildmenu_pum_43.dump 2022-03-16 13:32:52.274521965 +0000 --- src/testdir/dumps/Test_wildmenu_pum_43.dump 2022-03-16 13:26:18.215158792 +0000 *************** *** 0 **** --- 1,10 ---- + | +0&#ffffff0@74 + |~+0#4040ff13&| @73 + |~| @73 + |~| @3| +0#0000001#ffd7ff255|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|j|u|m|p| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#e0e0e08|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53 + |:+0#0000000&|s|i|g|n| |u|n|p|l|a|c|e> @61 *** ../vim-8.2.4578/src/testdir/dumps/Test_wildmenu_pum_44.dump 2022-03-16 13:32:52.278521958 +0000 --- src/testdir/dumps/Test_wildmenu_pum_44.dump 2022-03-16 13:26:18.215158792 +0000 *************** *** 0 **** --- 1,10 ---- + | +0&#ffffff0@74 + |~+0#4040ff13&| @73 + |~| @73 + |~| @3| +0#0000001#ffd7ff255|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|j|u|m|p| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53 + |:+0#0000000&|s|i|g|n| > @68 *** ../vim-8.2.4578/src/testdir/dumps/Test_wildmenu_pum_45.dump 2022-03-16 13:32:52.282521951 +0000 --- src/testdir/dumps/Test_wildmenu_pum_45.dump 2022-03-16 13:26:18.215158792 +0000 *************** *** 0 **** --- 1,10 ---- + | +0&#ffffff0@74 + |~+0#4040ff13&| @73 + |~| @73 + |~| @3| +0#0000001#e0e0e08|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|j|u|m|p| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53 + |:+0#0000000&|s|i|g|n| |d|e|f|i|n|e> @62 *** ../vim-8.2.4578/src/testdir/dumps/Test_wildmenu_pum_46.dump 2022-03-16 13:32:52.286521944 +0000 --- src/testdir/dumps/Test_wildmenu_pum_46.dump 2022-03-16 13:26:18.215158792 +0000 *************** *** 0 **** --- 1,10 ---- + | +0&#ffffff0@74 + |~+0#4040ff13&| @73 + |~| @73 + |~| @3| +0#0000001#ffd7ff255|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|j|u|m|p| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#e0e0e08|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53 + |:+0#0000000&|s|i|g|n| |u|n|p|l|a|c|e> @61 *** ../vim-8.2.4578/src/testdir/dumps/Test_wildmenu_pum_47.dump 2022-03-16 13:32:52.290521937 +0000 --- src/testdir/dumps/Test_wildmenu_pum_47.dump 2022-03-16 13:26:18.215158792 +0000 *************** *** 0 **** --- 1,10 ---- + | +0&#ffffff0@74 + |~+0#4040ff13&| @73 + |~| @73 + |~| @3| +0#0000001#ffd7ff255|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|j|u|m|p| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53 + |:+0#0000000&|s|i|g|n| > @68 *** ../vim-8.2.4578/src/testdir/dumps/Test_wildmenu_pum_48.dump 2022-03-16 13:32:52.294521930 +0000 --- src/testdir/dumps/Test_wildmenu_pum_48.dump 2022-03-16 13:26:18.215158792 +0000 *************** *** 0 **** --- 1,10 ---- + | +0&#ffffff0@74 + |~+0#4040ff13&| @73 + |~| @73 + |~| @3| +0#0000001#ffd7ff255|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|j|u|m|p| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#e0e0e08|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53 + |:+0#0000000&|s|i|g|n| |u|n|p|l|a|c|e> @61 *** ../vim-8.2.4578/src/testdir/dumps/Test_wildmenu_pum_49.dump 2022-03-16 13:32:52.298521922 +0000 --- src/testdir/dumps/Test_wildmenu_pum_49.dump 2022-03-16 13:26:18.215158792 +0000 *************** *** 0 **** --- 1,10 ---- + | +0&#ffffff0@74 + |~+0#4040ff13&| @73 + |~| @73 + |~| @3| +0#0000001#ffd7ff255|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#e0e0e08|j|u|m|p| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53 + |:+0#0000000&|s|i|g|n| |j|u|m|p> @64 *** ../vim-8.2.4578/src/testdir/dumps/Test_wildmenu_pum_50.dump 2022-03-16 13:32:52.302521915 +0000 --- src/testdir/dumps/Test_wildmenu_pum_50.dump 2022-03-16 13:26:18.215158792 +0000 *************** *** 0 **** --- 1,10 ---- + | +0&#ffffff0@74 + |~+0#4040ff13&| @73 + |~| @73 + |~| @3| +0#0000001#e0e0e08|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|j|u|m|p| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53 + |~| @3| +0#0000001#ffd7ff255|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53 + |:+0#0000000&|s|i|g|n| |d|e|f|i|n|e> @62 *** ../vim-8.2.4578/src/version.c 2022-03-16 13:09:11.329619036 +0000 --- src/version.c 2022-03-16 13:27:14.035079618 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4579, /**/ -- MAN: You don't frighten us, English pig-dog! Go and boil your bottoms, son of a silly person. I blow my nose on you, so-called Arthur-king, you and your silly English K...kaniggets. He puts hands to his ears and blows a raspberry. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///