aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-05-20 21:14:59 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-05-21 23:01:11 -0400
commit39fdb868322fe32f2dcc7187b6f2f698e24b93f8 (patch)
treef0db7ecbfac51fa24a8cfe1560b1453334977a03 /src
parent4dadbe64a03b67b1c61b1ed4a8fcdff085fa506d (diff)
downloadrneovim-39fdb868322fe32f2dcc7187b6f2f698e24b93f8.tar.gz
rneovim-39fdb868322fe32f2dcc7187b6f2f698e24b93f8.tar.bz2
rneovim-39fdb868322fe32f2dcc7187b6f2f698e24b93f8.zip
vim-patch:8.2.0946: cannot use "q" to cancel a number prompt
Problem: Cannot use "q" to cancel a number prompt. Solution: Recognize "q" instead of ignoring it. https://github.com/vim/vim/commit/eebd555733491cb55b9f30fe28772c0fd0ebacf7
Diffstat (limited to 'src')
-rw-r--r--src/nvim/misc1.c15
-rw-r--r--src/nvim/testdir/test_functions.vim12
2 files changed, 21 insertions, 6 deletions
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index 68a1bba78d..795af3d94a 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -753,8 +753,9 @@ get_number (
skip_redraw = TRUE; /* skip redraw once */
do_redraw = FALSE;
break;
- } else if (c == CAR || c == NL || c == Ctrl_C || c == ESC)
+ } else if (c == CAR || c == NL || c == Ctrl_C || c == ESC || c == 'q') {
break;
+ }
}
no_mapping--;
return n;
@@ -771,11 +772,13 @@ int prompt_for_number(int *mouse_used)
int save_cmdline_row;
int save_State;
- /* When using ":silent" assume that <CR> was entered. */
- if (mouse_used != NULL)
- MSG_PUTS(_("Type number and <Enter> or click with mouse (empty cancels): "));
- else
- MSG_PUTS(_("Type number and <Enter> (empty cancels): "));
+ // When using ":silent" assume that <CR> was entered.
+ if (mouse_used != NULL) {
+ MSG_PUTS(_("Type number and <Enter> or click with the mouse "
+ "(q or empty cancels): "));
+ } else {
+ MSG_PUTS(_("Type number and <Enter> (q or empty cancels): "));
+ }
/* Set the state such that text can be selected/copied/pasted and we still
* get mouse events. */
diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim
index 15b5bffd81..b81dce9940 100644
--- a/src/nvim/testdir/test_functions.vim
+++ b/src/nvim/testdir/test_functions.vim
@@ -1067,6 +1067,18 @@ func Test_inputlist()
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>3\<cr>", 'tx')
call assert_equal(3, c)
+ " CR to cancel
+ call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>\<cr>", 'tx')
+ call assert_equal(0, c)
+
+ " Esc to cancel
+ call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>\<Esc>", 'tx')
+ call assert_equal(0, c)
+
+ " q to cancel
+ call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>q", 'tx')
+ call assert_equal(0, c)
+
call assert_fails('call inputlist("")', 'E686:')
endfunc