From 8c3244c9a1c4b82ab86431f173716ce606b83813 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Feb 2022 04:46:16 +0800 Subject: vim-patch:8.2.2363: curpos() does not accept a string argument as before Problem: curpos() does not accept a string argument as before. solution: Make a string argument work again. (Yegappan Lakshmanan, closes vim/vim#7690 https://github.com/vim/vim/commit/9ebcf231bdccc1673cc92b20f5190fc577ad29d0 --- src/nvim/eval/funcs.c | 2 +- src/nvim/testdir/test_cursor_func.vim | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index b188ded368..edf6ed3c12 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -1584,7 +1584,7 @@ static void set_cursorpos(typval_T *argvars, typval_T *rettv, bool charcol) set_curswant = false; } } else if ((argvars[0].v_type == VAR_NUMBER || argvars[0].v_type == VAR_STRING) - && argvars[1].v_type == VAR_NUMBER) { + && (argvars[1].v_type == VAR_NUMBER || argvars[1].v_type == VAR_STRING)) { line = tv_get_lnum(argvars); col = (long)tv_get_number_chk(&argvars[1], NULL); if (charcol) { diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim index d8b3ac3fcc..f2ffd50726 100644 --- a/src/nvim/testdir/test_cursor_func.vim +++ b/src/nvim/testdir/test_cursor_func.vim @@ -24,6 +24,9 @@ func Test_move_cursor() " below last line goes to last line call cursor(9, 1) call assert_equal([4, 1, 0, 1], getcurpos()[1:]) + " pass string arguments + call cursor('3', '3') + call assert_equal([3, 3, 0, 3], getcurpos()[1:]) call setline(1, ["\"]) call cursor(1, 1, 1) -- cgit