Mercurial > vim
diff src/testdir/test_cursor_func.vim @ 31057:1a32f1a4f823 v9.0.0863
patch 9.0.0863: col() and charcol() only work for the current window
Commit: https://github.com/vim/vim/commit/4c8d2f02b3ce037bbe1d5ee12887e343c6bde88f
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sat Nov 12 16:07:47 2022 +0000
patch 9.0.0863: col() and charcol() only work for the current window
Problem: col() and charcol() only work for the current window.
Solution: Add an optional winid argument. (Yegappan Lakshmanan,
closes #11466, closes #11461)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 12 Nov 2022 17:15:03 +0100 |
parents | b7efd41d43b8 |
children | 45a03dd92f28 |
line wrap: on
line diff
--- a/src/testdir/test_cursor_func.vim +++ b/src/testdir/test_cursor_func.vim @@ -287,8 +287,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']) @@ -344,6 +345,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