Mercurial > vim
changeset 23507:88a7e3bbb594 v8.2.2296
patch 8.2.2296: cannot use CTRL-N and CTRL-P in a popup menu
Commit: https://github.com/vim/vim/commit/014f698cb68ff80c49f9f5d3dbe78127df281885
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 4 13:18:30 2021 +0100
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 https://github.com/vim/vim/issues/7614)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 04 Jan 2021 13:30:03 +0100 |
parents | 8d4f034c1776 |
children | 66c2449bef2e |
files | runtime/doc/popup.txt src/popupwin.c src/testdir/test_popupwin.vim src/version.c |
diffstat | 4 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/runtime/doc/popup.txt +++ b/runtime/doc/popup.txt @@ -309,8 +309,8 @@ popup_dialog({what}, {options}) *popu 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.
--- a/src/popupwin.c +++ b/src/popupwin.c @@ -2380,9 +2380,10 @@ f_popup_filter_menu(typval_T *argvars, t 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)
--- 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("\<c-n>\<c-n>\<c-p>\<cr>", 'xt') +endfunc + " vim: shiftwidth=2 sts=2