]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.2296: cannot use CTRL-N and CTRL-P in a popup menu v8.2.2296
authorBram Moolenaar <Bram@vim.org>
Mon, 4 Jan 2021 12:18:30 +0000 (13:18 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 4 Jan 2021 12:18:30 +0000 (13:18 +0100)
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)

runtime/doc/popup.txt
src/popupwin.c
src/testdir/test_popupwin.vim
src/version.c

index be0b7e21338a307fe96abe4d4a87a55b368e628e..54302a95d86d82f6a05da922355413bbced7ee1c 100644 (file)
@@ -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.
index 7896efd2100fd0fe361f0ed769cb531e999336e2..fddcaa1b4e3283754c6f296e5e5120e13fc7ea50 100644 (file)
@@ -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)
index bfc049438a06357faca20a6f58cb20bc03ee8204..7335c1c13ab2087c2ebbe925e9e48148deb0e46a 100644 (file)
@@ -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
index 12877de0a0e4d5deb17e29d449466e5ce6b1a1b7..7be57284fdab6149826c1543d3dd6be00e3c699c 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2296,
 /**/
     2295,
 /**/