aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_getln.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-01-15 07:01:14 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-01-15 07:36:58 +0800
commit066a1a069b2b0d97308ed2bdb18fbef488051e12 (patch)
treee1924b5e59dfba842f034873a55fec50b62bb819 /src/nvim/ex_getln.c
parent44710a91d06cdd6cba01a2d62fc9652f94651363 (diff)
downloadrneovim-066a1a069b2b0d97308ed2bdb18fbef488051e12.tar.gz
rneovim-066a1a069b2b0d97308ed2bdb18fbef488051e12.tar.bz2
rneovim-066a1a069b2b0d97308ed2bdb18fbef488051e12.zip
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) https://github.com/vim/vim/commit/5cffa8df7e3c28681b9e5deef6df395784359b6b Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r--src/nvim/ex_getln.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 72208c976f..fc227f357e 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -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
- if (!(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) {
+ if (end_wildmenu) {
command_line_end_wildmenu(s);
}
@@ -2016,13 +2026,26 @@ static int command_line_handle_key(CommandLineState *s)
case K_KPAGEUP:
case K_PAGEDOWN:
case K_KPAGEDOWN:
- switch (command_line_browse_history(s)) {
- case CMDLINE_CHANGED:
- return command_line_changed(s);
- case GOTO_NORMAL_MODE:
- return 0;
- default:
+ if (cmdline_pum_active()
+ && (s->c == K_PAGEUP || s->c == K_PAGEDOWN
+ || 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) {
+ break;
+ }
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