From 3865b4320591d35b6a87671f6864ee72c85a0e05 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 7 Jun 2021 20:21:21 -0400 Subject: vim-patch:8.2.2957: using getchar() in Vim9 script is problematic Problem: Using getchar() in Vim9 script is problematic. Solution: Add getcharstr(). (closes vim/vim#8343) https://github.com/vim/vim/commit/3a7503c34c65ed15cc08deb5b54aaf2ea51525b4 Cherry-pick Test_getchar() changes from patch v8.1.2304 to sync with upstream. Port f_getcharstr() to src/nvim/eval/funcs.c, not src/nvim/getchar.c. Patch v8.1.2042 is not ported yet. --- src/nvim/testdir/test_functions.vim | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 7c00b479a3..bcf2edcc93 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -1325,7 +1325,15 @@ endfunc func Test_getchar() call feedkeys('a', '') call assert_equal(char2nr('a'), getchar()) + call assert_equal(0, getchar(0)) + call assert_equal(0, getchar(1)) + call feedkeys('a', '') + call assert_equal('a', getcharstr()) + call assert_equal('', getcharstr(0)) + call assert_equal('', getcharstr(1)) + + call setline(1, 'xxxx') " call test_setmouse(1, 3) " let v:mouse_win = 9 " let v:mouse_winid = 9 @@ -1338,6 +1346,7 @@ func Test_getchar() call assert_equal(win_getid(1), v:mouse_winid) call assert_equal(1, v:mouse_lnum) call assert_equal(3, v:mouse_col) + enew! endfunc func Test_libcall_libcallnr() -- cgit