0
0
mirror of https://github.com/vim/vim.git synced 2025-09-28 04:24:06 -04:00

patch 9.0.1728: missing winid argument for virtcol()

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: #12633

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
This commit is contained in:
zeertzjq
2023-08-17 22:55:25 +02:00
committed by Christian Brabandt
parent b0efa49ed1
commit 825cf813fa
6 changed files with 84 additions and 12 deletions

View File

@@ -3514,12 +3514,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