Skip to content

Commit

Permalink
patch 8.2.2875: cancelling inputlist() after a digit does not return …
Browse files Browse the repository at this point in the history
…zero

Problem:    Cancelling inputlist() after a digit does not return zero.
Solution:   Always return zero when cancelling. (closes #8231)
  • Loading branch information
mark2185 authored and brammool committed May 20, 2021
1 parent 4eb1914 commit 5cf9457
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/misc1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/testdir/test_functions.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,10 @@ func Test_inputlist()
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>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'])\<cr>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'])\<cr>1\<BS>3\<BS>2\<cr>", 'tx')
call assert_equal(2, c)
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2875,
/**/
2874,
/**/
Expand Down

0 comments on commit 5cf9457

Please sign in to comment.