Skip to content

Commit 014f698

Browse files
committed
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)
1 parent d93a7fc commit 014f698

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

runtime/doc/popup.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ popup_dialog({what}, {options}) *popup_dialog()*
309309
310310
popup_filter_menu({id}, {key}) *popup_filter_menu()*
311311
Filter that can be used for a popup. These keys can be used:
312-
j <Down> select item below
313-
k <Up> select item above
312+
j <Down> <C-N> select item below
313+
k <Up> <C-P> select item above
314314
<Space> <Enter> accept current selection
315315
x Esc CTRL-C cancel the menu
316316
Other keys are ignored.

src/popupwin.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,9 +2380,10 @@ f_popup_filter_menu(typval_T *argvars, typval_T *rettv)
23802380
res.v_type = VAR_NUMBER;
23812381

23822382
old_lnum = wp->w_cursor.lnum;
2383-
if ((c == 'k' || c == 'K' || c == K_UP) && wp->w_cursor.lnum > 1)
2383+
if ((c == 'k' || c == 'K' || c == K_UP || c == Ctrl_P)
2384+
&& wp->w_cursor.lnum > 1)
23842385
--wp->w_cursor.lnum;
2385-
if ((c == 'j' || c == 'J' || c == K_DOWN)
2386+
if ((c == 'j' || c == 'J' || c == K_DOWN || c == Ctrl_N)
23862387
&& wp->w_cursor.lnum < wp->w_buffer->b_ml.ml_line_count)
23872388
++wp->w_cursor.lnum;
23882389
if (old_lnum != wp->w_cursor.lnum)

src/testdir/test_popupwin.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3797,4 +3797,10 @@ func Test_popupwin_exiting_terminal()
37973797
endtry
37983798
endfunc
37993799

3800+
func Test_popup_filter_menu()
3801+
let colors = ['red', 'green', 'blue']
3802+
call popup_menu(colors, #{callback: {_, result -> assert_equal('green', colors[result - 1])}})
3803+
call feedkeys("\<c-n>\<c-n>\<c-p>\<cr>", 'xt')
3804+
endfunc
3805+
38003806
" vim: shiftwidth=2 sts=2

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2296,
753755
/**/
754756
2295,
755757
/**/

0 commit comments

Comments
 (0)