# HG changeset patch # User Bram Moolenaar # Date 1591797605 -7200 # Node ID 072ad890c227d8361eb3061f67e6b33c6998f80c # Parent a17de379e6bde5a7b5f2863358f02382f019480f patch 8.2.0946: cannot use "q" to cancel a number prompt Commit: https://github.com/vim/vim/commit/eebd555733491cb55b9f30fe28772c0fd0ebacf7 Author: Bram Moolenaar Date: Wed Jun 10 15:45:57 2020 +0200 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. diff --git a/src/misc1.c b/src/misc1.c --- a/src/misc1.c +++ b/src/misc1.c @@ -945,7 +945,7 @@ get_number( 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; @@ -967,9 +967,9 @@ prompt_for_number(int *mouse_used) // When using ":silent" assume that was entered. if (mouse_used != NULL) - msg_puts(_("Type number and or click with mouse (empty cancels): ")); + msg_puts(_("Type number and or click with the mouse (q or empty cancels): ")); else - msg_puts(_("Type number and (empty cancels): ")); + msg_puts(_("Type number and (q or empty cancels): ")); // Set the state such that text can be selected/copied/pasted and we still // get mouse events. redraw_after_callback() will not redraw if cmdline_row diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -1371,6 +1371,18 @@ func Test_inputlist() call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\3\", 'tx') call assert_equal(3, c) + " CR to cancel + call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\\", 'tx') + call assert_equal(0, c) + + " Esc to cancel + call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\\", 'tx') + call assert_equal(0, c) + + " q to cancel + call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\q", 'tx') + call assert_equal(0, c) + " Use backspace to delete characters in the prompt call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\1\3\2\", 'tx') call assert_equal(2, c) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 946, +/**/ 945, /**/ 944,