Skip to content

Commit 5cf9457

Browse files
mark2185brammool
authored andcommitted
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 #8231)
1 parent 4eb1914 commit 5cf9457

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/misc1.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,12 @@ get_number(
946946
do_redraw = FALSE;
947947
break;
948948
}
949-
else if (c == CAR || c == NL || c == Ctrl_C || c == ESC || c == 'q')
949+
else if (c == Ctrl_C || c == ESC || c == 'q')
950+
{
951+
n = 0;
952+
break;
953+
}
954+
else if (c == CAR || c == NL )
950955
break;
951956
}
952957
--no_mapping;

src/testdir/test_functions.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,10 @@ func Test_inputlist()
14801480
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>q", 'tx')
14811481
call assert_equal(0, c)
14821482

1483+
" Cancel after inputting a number
1484+
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>5q", 'tx')
1485+
call assert_equal(0, c)
1486+
14831487
" Use backspace to delete characters in the prompt
14841488
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>1\<BS>3\<BS>2\<cr>", 'tx')
14851489
call assert_equal(2, c)

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2875,
753755
/**/
754756
2874,
755757
/**/

0 commit comments

Comments
 (0)