# HG changeset patch # User Bram Moolenaar # Date 1621538104 -7200 # Node ID 53fd6370e4fd3f578f600d8a3df4f066b7f8cd50 # Parent f228c8088d9a0cd3f4035bf4a4d4bb8d62b28fb9 patch 8.2.2875: cancelling inputlist() after a digit does not return zero Commit: https://github.com/vim/vim/commit/5cf94577cf2045fec87344d7d89422fe6dfce62f Author: =?UTF-8?q?Luka=20Marku=C5=A1i=C4=87?= Date: Thu May 20 21:14:20 2021 +0200 patch 8.2.2875: cancelling inputlist() after a digit does not return zero Problem: Cancelling inputlist() after a digit does not return zero. Solution: Always return zero when cancelling. (closes https://github.com/vim/vim/issues/8231) diff --git a/src/misc1.c b/src/misc1.c --- a/src/misc1.c +++ b/src/misc1.c @@ -946,7 +946,12 @@ get_number( do_redraw = FALSE; break; } - else if (c == CAR || c == NL || c == Ctrl_C || c == ESC || c == 'q') + else if (c == Ctrl_C || c == ESC || c == 'q') + { + n = 0; + break; + } + else if (c == CAR || c == NL ) break; } --no_mapping; 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 @@ -1480,6 +1480,10 @@ func Test_inputlist() call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\q", 'tx') call assert_equal(0, c) + " Cancel after inputting a number + call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\5q", '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 @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2875, +/**/ 2874, /**/ 2873,