1
0
forked from aniani/vim

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)
This commit is contained in:
Yegappan Lakshmanan
2022-11-12 16:07:47 +00:00
committed by Bram Moolenaar
parent 0aad88f073
commit 4c8d2f02b3
7 changed files with 75 additions and 15 deletions

View File

@@ -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