From 014f698cb68ff80c49f9f5d3dbe78127df281885 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 4 Jan 2021 13:18:30 +0100 Subject: 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 and CTRL-P like . (closes #7614) --- runtime/doc/popup.txt | 4 ++-- src/popupwin.c | 5 +++-- src/testdir/test_popupwin.vim | 6 ++++++ src/version.c | 2 ++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/runtime/doc/popup.txt b/runtime/doc/popup.txt index be0b7e213..54302a95d 100644 --- a/runtime/doc/popup.txt +++ b/runtime/doc/popup.txt @@ -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 select item below - k select item above + j select item below + k select item above accept current selection x Esc CTRL-C cancel the menu Other keys are ignored. diff --git a/src/popupwin.c b/src/popupwin.c index 7896efd21..fddcaa1b4 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -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) diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim index bfc049438..7335c1c13 100644 --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -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("\\\\", 'xt') +endfunc + " vim: shiftwidth=2 sts=2 diff --git a/src/version.c b/src/version.c index 12877de0a..7be57284f 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2296, /**/ 2295, /**/ -- cgit v1.2.1