aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-01-15 07:23:51 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-01-15 07:36:58 +0800
commit940643aa331e31678467c770b77808e0b4240b34 (patch)
treed0fb1562b4281efd1f9b3453c649d625321ebcb3
parent066a1a069b2b0d97308ed2bdb18fbef488051e12 (diff)
downloadrneovim-940643aa331e31678467c770b77808e0b4240b34.tar.gz
rneovim-940643aa331e31678467c770b77808e0b4240b34.tar.bz2
rneovim-940643aa331e31678467c770b77808e0b4240b34.zip
vim-patch:8.2.4585: cannot use keypad page-up/down for completion menu
Problem: Cannot use keypad page-up/down for completion menu. Solution: Recognize the keypad keys. (Yegappan Lakshmanan, closes vim/vim#9963) https://github.com/vim/vim/commit/155b0882088ff115dcfb6ce466fe7c8cc2bef349 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
-rw-r--r--src/nvim/ex_getln.c10
-rw-r--r--src/nvim/testdir/test_cmdline.vim20
2 files changed, 16 insertions, 14 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index fc227f357e..62586598bf 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -2010,8 +2010,8 @@ static int command_line_handle_key(CommandLineState *s)
case Ctrl_N: // next match
case Ctrl_P: // previous match
if (s->xpc.xp_numfiles > 0) {
- if (nextwild(&s->xpc, (s->c == Ctrl_P) ? WILD_PREV : WILD_NEXT,
- 0, s->firstc != '@') == FAIL) {
+ const int wild_type = (s->c == Ctrl_P) ? WILD_PREV : WILD_NEXT;
+ if (nextwild(&s->xpc, wild_type, 0, s->firstc != '@') == FAIL) {
break;
}
return command_line_not_changed(s);
@@ -2031,9 +2031,9 @@ static int command_line_handle_key(CommandLineState *s)
|| s->c == K_KPAGEUP || s->c == K_KPAGEDOWN)) {
// If the popup menu is displayed, then PageUp and PageDown
// are used to scroll the menu.
- if (nextwild(&s->xpc,
- (s->c == K_PAGEUP) ? WILD_PAGEUP : WILD_PAGEDOWN,
- 0, s->firstc != '@') == FAIL) {
+ const int wild_type =
+ (s->c == K_PAGEDOWN || s->c == K_KPAGEDOWN) ? WILD_PAGEDOWN : WILD_PAGEUP;
+ if (nextwild(&s->xpc, wild_type, 0, s->firstc != '@') == FAIL) {
break;
}
return command_line_not_changed(s);
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index 50bdfceebd..c867639832 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -2206,7 +2206,8 @@ func Test_wildmenu_dirstack()
endfunc
" Test for recalling newer or older cmdline from history with <Up>, <Down>,
-" <S-Up>, <S-Down>, <PageUp>, <PageDown>, <C-p>, or <C-n>.
+" <S-Up>, <S-Down>, <PageUp>, <PageDown>, <kPageUp>, <kPageDown>, <C-p>, or
+" <C-n>.
func Test_recalling_cmdline()
CheckFeature cmdline_hist
@@ -2214,17 +2215,18 @@ func Test_recalling_cmdline()
cnoremap <Plug>(save-cmdline) <Cmd>let g:cmdlines += [getcmdline()]<CR>
let histories = [
- \ {'name': 'cmd', 'enter': ':', 'exit': "\<Esc>"},
- \ {'name': 'search', 'enter': '/', 'exit': "\<Esc>"},
- \ {'name': 'expr', 'enter': ":\<C-r>=", 'exit': "\<Esc>\<Esc>"},
- \ {'name': 'input', 'enter': ":call input('')\<CR>", 'exit': "\<CR>"},
+ \ #{name: 'cmd', enter: ':', exit: "\<Esc>"},
+ \ #{name: 'search', enter: '/', exit: "\<Esc>"},
+ \ #{name: 'expr', enter: ":\<C-r>=", exit: "\<Esc>\<Esc>"},
+ \ #{name: 'input', enter: ":call input('')\<CR>", exit: "\<CR>"},
"\ TODO: {'name': 'debug', ...}
\]
let keypairs = [
- \ {'older': "\<Up>", 'newer': "\<Down>", 'prefixmatch': v:true},
- \ {'older': "\<S-Up>", 'newer': "\<S-Down>", 'prefixmatch': v:false},
- \ {'older': "\<PageUp>", 'newer': "\<PageDown>", 'prefixmatch': v:false},
- \ {'older': "\<C-p>", 'newer': "\<C-n>", 'prefixmatch': v:false},
+ \ #{older: "\<Up>", newer: "\<Down>", prefixmatch: v:true},
+ \ #{older: "\<S-Up>", newer: "\<S-Down>", prefixmatch: v:false},
+ \ #{older: "\<PageUp>", newer: "\<PageDown>", prefixmatch: v:false},
+ \ #{older: "\<kPageUp>", newer: "\<kPageDown>", prefixmatch: v:false},
+ \ #{older: "\<C-p>", newer: "\<C-n>", prefixmatch: v:false},
\]
let prefix = 'vi'
for h in histories