mirror of
https://github.com/neovim/neovim.git
synced 2025-10-02 16:08:36 +00:00
vim-patch:8.2.4579: cannot use page-up and page-down in the cmdline popup menu
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 vim/vim#9960)
5cffa8df7e
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
@@ -217,7 +217,9 @@ int nextwild(expand_T *xp, int type, int options, bool escape)
|
|||||||
assert(ccline->cmdpos >= i);
|
assert(ccline->cmdpos >= i);
|
||||||
xp->xp_pattern_len = (size_t)ccline->cmdpos - (size_t)i;
|
xp->xp_pattern_len = (size_t)ccline->cmdpos - (size_t)i;
|
||||||
|
|
||||||
if (type == WILD_NEXT || type == WILD_PREV || type == WILD_PUM_WANT) {
|
if (type == WILD_NEXT || type == WILD_PREV
|
||||||
|
|| type == WILD_PAGEUP || type == WILD_PAGEDOWN
|
||||||
|
|| type == WILD_PUM_WANT) {
|
||||||
// Get next/previous match for a previous expanded pattern.
|
// Get next/previous match for a previous expanded pattern.
|
||||||
p2 = ExpandOne(xp, NULL, NULL, 0, type);
|
p2 = ExpandOne(xp, NULL, NULL, 0, type);
|
||||||
} else {
|
} else {
|
||||||
@@ -593,6 +595,44 @@ static char *get_next_or_prev_match(int mode, expand_T *xp, int *p_findex, char
|
|||||||
findex--;
|
findex--;
|
||||||
} else if (mode == WILD_NEXT) {
|
} else if (mode == WILD_NEXT) {
|
||||||
findex++;
|
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
|
||||||
|
int ht = pum_get_height();
|
||||||
|
if (ht > 3) {
|
||||||
|
ht -= 2;
|
||||||
|
}
|
||||||
|
findex -= ht;
|
||||||
|
if (findex < 0) {
|
||||||
|
// few entries left, select the first entry
|
||||||
|
findex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (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
|
||||||
|
int 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else { // mode == WILD_PUM_WANT
|
} else { // mode == WILD_PUM_WANT
|
||||||
assert(pum_want.active);
|
assert(pum_want.active);
|
||||||
findex = pum_want.item;
|
findex = pum_want.item;
|
||||||
@@ -770,7 +810,9 @@ char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
// first handle the case of using an old match
|
// first handle the case of using an old match
|
||||||
if (mode == WILD_NEXT || mode == WILD_PREV || mode == WILD_PUM_WANT) {
|
if (mode == WILD_NEXT || mode == WILD_PREV
|
||||||
|
|| mode == WILD_PAGEUP || mode == WILD_PAGEDOWN
|
||||||
|
|| mode == WILD_PUM_WANT) {
|
||||||
return get_next_or_prev_match(mode, xp, &findex, orig_save);
|
return get_next_or_prev_match(mode, xp, &findex, orig_save);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,8 +19,8 @@ enum {
|
|||||||
WILD_ALL_KEEP = 8,
|
WILD_ALL_KEEP = 8,
|
||||||
WILD_CANCEL = 9,
|
WILD_CANCEL = 9,
|
||||||
WILD_APPLY = 10,
|
WILD_APPLY = 10,
|
||||||
// WILD_PAGEUP = 11, not ported yet
|
WILD_PAGEUP = 11,
|
||||||
// WILD_PAGEDOWN = 12, not ported yet
|
WILD_PAGEDOWN = 12,
|
||||||
WILD_PUM_WANT = 13,
|
WILD_PUM_WANT = 13,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1234,10 +1234,20 @@ static int command_line_execute(VimState *state, int key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
bool end_wildmenu = (!(s->c == p_wc && KeyTyped) && s->c != p_wcm && s->c != Ctrl_Z
|
||||||
|
&& s->c != Ctrl_N && s->c != Ctrl_P && s->c != Ctrl_A
|
||||||
|
&& s->c != Ctrl_L);
|
||||||
|
end_wildmenu = end_wildmenu && (!cmdline_pum_active()
|
||||||
|
|| (s->c != K_PAGEDOWN && s->c != K_PAGEUP
|
||||||
|
&& s->c != K_KPAGEDOWN && s->c != K_KPAGEUP));
|
||||||
|
|
||||||
// free expanded names when finished walking through matches
|
// free expanded names when finished walking through matches
|
||||||
if (!(s->c == p_wc && KeyTyped) && s->c != p_wcm && s->c != Ctrl_Z
|
if (end_wildmenu) {
|
||||||
&& s->c != Ctrl_N && s->c != Ctrl_P && s->c != Ctrl_A
|
|
||||||
&& s->c != Ctrl_L) {
|
|
||||||
command_line_end_wildmenu(s);
|
command_line_end_wildmenu(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2016,13 +2026,26 @@ static int command_line_handle_key(CommandLineState *s)
|
|||||||
case K_KPAGEUP:
|
case K_KPAGEUP:
|
||||||
case K_PAGEDOWN:
|
case K_PAGEDOWN:
|
||||||
case K_KPAGEDOWN:
|
case K_KPAGEDOWN:
|
||||||
switch (command_line_browse_history(s)) {
|
if (cmdline_pum_active()
|
||||||
case CMDLINE_CHANGED:
|
&& (s->c == K_PAGEUP || s->c == K_PAGEDOWN
|
||||||
return command_line_changed(s);
|
|| s->c == K_KPAGEUP || s->c == K_KPAGEDOWN)) {
|
||||||
case GOTO_NORMAL_MODE:
|
// If the popup menu is displayed, then PageUp and PageDown
|
||||||
return 0;
|
// are used to scroll the menu.
|
||||||
default:
|
if (nextwild(&s->xpc,
|
||||||
|
(s->c == K_PAGEUP) ? WILD_PAGEUP : WILD_PAGEDOWN,
|
||||||
|
0, s->firstc != '@') == FAIL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
return command_line_not_changed(s);
|
return command_line_not_changed(s);
|
||||||
|
} else {
|
||||||
|
switch (command_line_browse_history(s)) {
|
||||||
|
case CMDLINE_CHANGED:
|
||||||
|
return command_line_changed(s);
|
||||||
|
case GOTO_NORMAL_MODE:
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
return command_line_not_changed(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case Ctrl_G: // next match
|
case Ctrl_G: // next match
|
||||||
|
@@ -151,6 +151,14 @@ func Test_complete_wildmenu()
|
|||||||
call assert_equal('"e Xdir1/Xdir2/1', @:)
|
call assert_equal('"e Xdir1/Xdir2/1', @:)
|
||||||
cunmap <F2>
|
cunmap <F2>
|
||||||
|
|
||||||
|
" Test for canceling the wild menu by pressing <PageDown> or <PageUp>.
|
||||||
|
" After this pressing <Left> or <Right> should not change the selection.
|
||||||
|
call feedkeys(":sign \<Tab>\<PageDown>\<Left>\<Right>\<C-A>\<C-B>\"\<CR>", 'tx')
|
||||||
|
call assert_equal('"sign define', @:)
|
||||||
|
call histadd('cmd', 'TestWildMenu')
|
||||||
|
call feedkeys(":sign \<Tab>\<PageUp>\<Left>\<Right>\<C-A>\<C-B>\"\<CR>", 'tx')
|
||||||
|
call assert_equal('"TestWildMenu', @:)
|
||||||
|
|
||||||
" cleanup
|
" cleanup
|
||||||
%bwipe
|
%bwipe
|
||||||
call delete('Xdir1', 'rf')
|
call delete('Xdir1', 'rf')
|
||||||
@@ -2539,6 +2547,28 @@ func Test_wildmenu_pum()
|
|||||||
call VerifyScreenDump(buf, 'Test_wildmenu_pum_41', {})
|
call VerifyScreenDump(buf, 'Test_wildmenu_pum_41', {})
|
||||||
call term_sendkeys(buf, "\<Esc>")
|
call term_sendkeys(buf, "\<Esc>")
|
||||||
|
|
||||||
|
" Pressing <PageDown> should scroll the menu downward
|
||||||
|
call term_sendkeys(buf, ":sign \<Tab>\<PageDown>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_wildmenu_pum_42', {})
|
||||||
|
call term_sendkeys(buf, "\<PageDown>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_wildmenu_pum_43', {})
|
||||||
|
call term_sendkeys(buf, "\<PageDown>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_wildmenu_pum_44', {})
|
||||||
|
call term_sendkeys(buf, "\<PageDown>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_wildmenu_pum_45', {})
|
||||||
|
call term_sendkeys(buf, "\<C-U>sign \<Tab>\<Down>\<Down>\<PageDown>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_wildmenu_pum_46', {})
|
||||||
|
|
||||||
|
" Pressing <PageUp> should scroll the menu upward
|
||||||
|
call term_sendkeys(buf, "\<C-U>sign \<Tab>\<PageUp>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_wildmenu_pum_47', {})
|
||||||
|
call term_sendkeys(buf, "\<PageUp>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_wildmenu_pum_48', {})
|
||||||
|
call term_sendkeys(buf, "\<PageUp>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_wildmenu_pum_49', {})
|
||||||
|
call term_sendkeys(buf, "\<PageUp>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_wildmenu_pum_50', {})
|
||||||
|
|
||||||
call term_sendkeys(buf, "\<C-U>\<CR>")
|
call term_sendkeys(buf, "\<C-U>\<CR>")
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
call delete('Xtest')
|
call delete('Xtest')
|
||||||
|
@@ -2388,8 +2388,130 @@ describe('builtin popupmenu', function()
|
|||||||
{1:~ }{n: xyz }{1: }|
|
{1:~ }{n: xyz }{1: }|
|
||||||
:e あいう/123^ |
|
:e あいう/123^ |
|
||||||
]])
|
]])
|
||||||
|
feed('<Esc>')
|
||||||
|
|
||||||
feed('<esc>')
|
-- Pressing <PageDown> should scroll the menu downward
|
||||||
|
feed(':sign <Tab><PageDown>')
|
||||||
|
screen:expect([[
|
||||||
|
|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }{n: define }{1: }|
|
||||||
|
{1:~ }{n: jump }{1: }|
|
||||||
|
{1:~ }{n: list }{1: }|
|
||||||
|
{1:~ }{n: place }{1: }|
|
||||||
|
{1:~ }{s: undefine }{1: }|
|
||||||
|
{1:~ }{n: unplace }{1: }|
|
||||||
|
:sign undefine^ |
|
||||||
|
]])
|
||||||
|
feed('<PageDown>')
|
||||||
|
screen:expect([[
|
||||||
|
|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }{n: define }{1: }|
|
||||||
|
{1:~ }{n: jump }{1: }|
|
||||||
|
{1:~ }{n: list }{1: }|
|
||||||
|
{1:~ }{n: place }{1: }|
|
||||||
|
{1:~ }{n: undefine }{1: }|
|
||||||
|
{1:~ }{s: unplace }{1: }|
|
||||||
|
:sign unplace^ |
|
||||||
|
]])
|
||||||
|
feed('<PageDown>')
|
||||||
|
screen:expect([[
|
||||||
|
|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }{n: define }{1: }|
|
||||||
|
{1:~ }{n: jump }{1: }|
|
||||||
|
{1:~ }{n: list }{1: }|
|
||||||
|
{1:~ }{n: place }{1: }|
|
||||||
|
{1:~ }{n: undefine }{1: }|
|
||||||
|
{1:~ }{n: unplace }{1: }|
|
||||||
|
:sign ^ |
|
||||||
|
]])
|
||||||
|
feed('<PageDown>')
|
||||||
|
screen:expect([[
|
||||||
|
|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }{s: define }{1: }|
|
||||||
|
{1:~ }{n: jump }{1: }|
|
||||||
|
{1:~ }{n: list }{1: }|
|
||||||
|
{1:~ }{n: place }{1: }|
|
||||||
|
{1:~ }{n: undefine }{1: }|
|
||||||
|
{1:~ }{n: unplace }{1: }|
|
||||||
|
:sign define^ |
|
||||||
|
]])
|
||||||
|
feed('<C-U>sign <Tab><Right><Right><PageDown>')
|
||||||
|
screen:expect([[
|
||||||
|
|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }{n: define }{1: }|
|
||||||
|
{1:~ }{n: jump }{1: }|
|
||||||
|
{1:~ }{n: list }{1: }|
|
||||||
|
{1:~ }{n: place }{1: }|
|
||||||
|
{1:~ }{n: undefine }{1: }|
|
||||||
|
{1:~ }{s: unplace }{1: }|
|
||||||
|
:sign unplace^ |
|
||||||
|
]])
|
||||||
|
|
||||||
|
-- Pressing <PageUp> should scroll the menu upward
|
||||||
|
feed('<C-U>sign <Tab><PageUp>')
|
||||||
|
screen:expect([[
|
||||||
|
|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }{n: define }{1: }|
|
||||||
|
{1:~ }{n: jump }{1: }|
|
||||||
|
{1:~ }{n: list }{1: }|
|
||||||
|
{1:~ }{n: place }{1: }|
|
||||||
|
{1:~ }{n: undefine }{1: }|
|
||||||
|
{1:~ }{n: unplace }{1: }|
|
||||||
|
:sign ^ |
|
||||||
|
]])
|
||||||
|
feed('<PageUp>')
|
||||||
|
screen:expect([[
|
||||||
|
|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }{n: define }{1: }|
|
||||||
|
{1:~ }{n: jump }{1: }|
|
||||||
|
{1:~ }{n: list }{1: }|
|
||||||
|
{1:~ }{n: place }{1: }|
|
||||||
|
{1:~ }{n: undefine }{1: }|
|
||||||
|
{1:~ }{s: unplace }{1: }|
|
||||||
|
:sign unplace^ |
|
||||||
|
]])
|
||||||
|
feed('<PageUp>')
|
||||||
|
screen:expect([[
|
||||||
|
|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }{n: define }{1: }|
|
||||||
|
{1:~ }{s: jump }{1: }|
|
||||||
|
{1:~ }{n: list }{1: }|
|
||||||
|
{1:~ }{n: place }{1: }|
|
||||||
|
{1:~ }{n: undefine }{1: }|
|
||||||
|
{1:~ }{n: unplace }{1: }|
|
||||||
|
:sign jump^ |
|
||||||
|
]])
|
||||||
|
feed('<PageUp>')
|
||||||
|
screen:expect([[
|
||||||
|
|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }{s: define }{1: }|
|
||||||
|
{1:~ }{n: jump }{1: }|
|
||||||
|
{1:~ }{n: list }{1: }|
|
||||||
|
{1:~ }{n: place }{1: }|
|
||||||
|
{1:~ }{n: undefine }{1: }|
|
||||||
|
{1:~ }{n: unplace }{1: }|
|
||||||
|
:sign define^ |
|
||||||
|
]])
|
||||||
|
|
||||||
|
feed('<Esc>')
|
||||||
|
|
||||||
-- check positioning with multibyte char in pattern
|
-- check positioning with multibyte char in pattern
|
||||||
command("e långfile1")
|
command("e långfile1")
|
||||||
|
Reference in New Issue
Block a user