vim-patch:9.0.1728: missing winid argument for virtcol() (#24770)

Problem: missing winid argument for virtcol()
Solution: Add a {winid} argument to virtcol()

Other functions col(), charcol() and virtcol2col() support a {winid}
argument, so it makes sense for virtcol() to also support than.

Also add test for virtcol2col() with 'showbreak' and {winid}.

closes: vim/vim#12633

825cf813fa
This commit is contained in:
zeertzjq
2023-08-18 08:42:45 +08:00
committed by GitHub
parent 46163ddf5d
commit f8afa8023e
6 changed files with 92 additions and 20 deletions

View File

@@ -3093,12 +3093,32 @@ endfunc
" Test for virtcol()
func Test_virtcol()
enew!
new
call setline(1, "the\tquick\tbrown\tfox")
norm! 4|
call assert_equal(8, virtcol('.'))
call assert_equal(8, virtcol('.', v:false))
call assert_equal([4, 8], virtcol('.', v:true))
let w = winwidth(0)
call setline(2, repeat('a', w + 2))
let win_nosbr = win_getid()
split
setlocal showbreak=!!
let win_sbr = win_getid()
call assert_equal([w, w], virtcol([2, w], v:true, win_nosbr))
call assert_equal([w + 1, w + 1], virtcol([2, w + 1], v:true, win_nosbr))
call assert_equal([w + 2, w + 2], virtcol([2, w + 2], v:true, win_nosbr))
call assert_equal([w, w], virtcol([2, w], v:true, win_sbr))
call assert_equal([w + 3, w + 3], virtcol([2, w + 1], v:true, win_sbr))
call assert_equal([w + 4, w + 4], virtcol([2, w + 2], v:true, win_sbr))
close
call assert_equal(0, virtcol(''))
call assert_equal([0, 0], virtcol('', v:true))
call assert_equal(0, virtcol('.', v:false, 5001))
call assert_equal([0, 0], virtcol('.', v:true, 5001))
bwipe!
endfunc