diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2022-11-13 08:29:05 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-13 08:29:05 +0800 |
| commit | 849394e4e26f487586761a3640475c27ceca30b9 (patch) | |
| tree | 9d77b58ace60d150dd42c617cdab2af0495c2a5e /src/nvim/testdir | |
| parent | ec449c27fdad6cc907a6f4835ce28f31990ad519 (diff) | |
| download | rneovim-849394e4e26f487586761a3640475c27ceca30b9.tar.gz rneovim-849394e4e26f487586761a3640475c27ceca30b9.tar.bz2 rneovim-849394e4e26f487586761a3640475c27ceca30b9.zip | |
vim-patch:9.0.0863: col() and charcol() only work for the current window (#21038)
Problem: col() and charcol() only work for the current window.
Solution: Add an optional winid argument. (Yegappan Lakshmanan,
closes vim/vim#11466, closes vim/vim#11461)
https://github.com/vim/vim/commit/4c8d2f02b3ce037bbe1d5ee12887e343c6bde88f
Cherry-pick test_functions.vim change from patch 8.2.0633.
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/testdir')
| -rw-r--r-- | src/nvim/testdir/test_cursor_func.vim | 24 | ||||
| -rw-r--r-- | src/nvim/testdir/test_functions.vim | 12 |
2 files changed, 34 insertions, 2 deletions
diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim index 9801a45915..7f9e74e94b 100644 --- a/src/nvim/testdir/test_cursor_func.vim +++ b/src/nvim/testdir/test_cursor_func.vim @@ -241,8 +241,9 @@ endfunc " Test for the charcol() function func Test_charcol() - call assert_fails('call charcol({})', 'E731:') - call assert_equal(0, charcol(0)) + call assert_fails('call charcol({})', 'E1222:') + call assert_fails('call charcol(".", [])', 'E1210:') + call assert_fails('call charcol(0)', 'E1222:') new call setline(1, ['', "01\tà4è678", 'Ⅵ', '012345678']) @@ -298,6 +299,25 @@ func Test_charcol() call assert_equal([1, 10, 2, 10, 7], g:InsertCurrentCol) iunmap <F3> + " Test for getting the column number in another window. + let winid = win_getid() + new + call win_execute(winid, 'normal 1G') + call assert_equal(1, charcol('.', winid)) + call assert_equal(1, charcol('$', winid)) + call win_execute(winid, 'normal 2G6l') + call assert_equal(7, charcol('.', winid)) + call assert_equal(10, charcol('$', winid)) + + " calling from another tab page also works + tabnew + call assert_equal(7, charcol('.', winid)) + call assert_equal(10, charcol('$', winid)) + tabclose + + " unknown window ID + call assert_equal(0, charcol('.', 10001)) + %bw! endfunc diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index aaef01bdf5..5ff544ab55 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -1288,6 +1288,9 @@ func Test_col() call assert_equal(0, col([2, '$'])) call assert_equal(0, col([1, 100])) call assert_equal(0, col([1])) + call assert_equal(0, col(v:_null_list)) + call assert_fails('let c = col({})', 'E1222:') + call assert_fails('let c = col(".", [])', 'E1210:') " test for getting the visual start column func T() @@ -1317,6 +1320,15 @@ func Test_col() call assert_equal(4, col('.')) set virtualedit& + " Test for getting the column number in another window + let winid = win_getid() + new + call win_execute(winid, 'normal 1G$') + call assert_equal(3, col('.', winid)) + call win_execute(winid, 'normal 2G') + call assert_equal(8, col('$', winid)) + call assert_equal(0, col('.', 5001)) + bw! endfunc |