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:
committed by
Bram Moolenaar
parent
0aad88f073
commit
4c8d2f02b3
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user