mirror of
https://github.com/vim/vim.git
synced 2025-07-04 23:07:33 -04:00
patch 8.2.2296: cannot use CTRL-N and CTRL-P in a popup menu
Problem: Cannot use CTRL-N and CTRL-P in a popup menu. Solution: Use CTRL-N like <Down> and CTRL-P like <Up>. (closes #7614)
This commit is contained in:
parent
d93a7fc1a9
commit
014f698cb6
@ -309,8 +309,8 @@ popup_dialog({what}, {options}) *popup_dialog()*
|
||||
|
||||
popup_filter_menu({id}, {key}) *popup_filter_menu()*
|
||||
Filter that can be used for a popup. These keys can be used:
|
||||
j <Down> select item below
|
||||
k <Up> select item above
|
||||
j <Down> <C-N> select item below
|
||||
k <Up> <C-P> select item above
|
||||
<Space> <Enter> accept current selection
|
||||
x Esc CTRL-C cancel the menu
|
||||
Other keys are ignored.
|
||||
|
@ -2380,9 +2380,10 @@ f_popup_filter_menu(typval_T *argvars, typval_T *rettv)
|
||||
res.v_type = VAR_NUMBER;
|
||||
|
||||
old_lnum = wp->w_cursor.lnum;
|
||||
if ((c == 'k' || c == 'K' || c == K_UP) && wp->w_cursor.lnum > 1)
|
||||
if ((c == 'k' || c == 'K' || c == K_UP || c == Ctrl_P)
|
||||
&& wp->w_cursor.lnum > 1)
|
||||
--wp->w_cursor.lnum;
|
||||
if ((c == 'j' || c == 'J' || c == K_DOWN)
|
||||
if ((c == 'j' || c == 'J' || c == K_DOWN || c == Ctrl_N)
|
||||
&& wp->w_cursor.lnum < wp->w_buffer->b_ml.ml_line_count)
|
||||
++wp->w_cursor.lnum;
|
||||
if (old_lnum != wp->w_cursor.lnum)
|
||||
|
@ -3797,4 +3797,10 @@ func Test_popupwin_exiting_terminal()
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
func Test_popup_filter_menu()
|
||||
let colors = ['red', 'green', 'blue']
|
||||
call popup_menu(colors, #{callback: {_, result -> assert_equal('green', colors[result - 1])}})
|
||||
call feedkeys("\<c-n>\<c-n>\<c-p>\<cr>", 'xt')
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2
|
||||
|
@ -750,6 +750,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
2296,
|
||||
/**/
|
||||
2295,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user