From 486050ebc94d125b6a30340ec595ef62956624a7 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 20 May 2021 21:21:29 -0400 Subject: vim-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 vim/vim#8231) https://github.com/vim/vim/commit/5cf94577cf2045fec87344d7d89422fe6dfce62f --- src/nvim/misc1.c | 5 ++++- src/nvim/testdir/test_functions.vim | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 795af3d94a..38d0a7dadf 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -753,7 +753,10 @@ get_number ( skip_redraw = TRUE; /* skip redraw once */ 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; } } diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index b81dce9940..85d1bc7076 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -1079,6 +1079,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) + call assert_fails('call inputlist("")', 'E686:') endfunc -- cgit