diff options
author | LemonBoy <thatlemon@gmail.com> | 2022-05-26 12:10:37 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-05-26 12:10:37 +0100 |
commit | 0f7a3e1de6f71e8e1423fe594890d6aa7f94e132 (patch) | |
tree | 1919df8f82148f2e7a89315a63b5d97622e47bd5 /src/testdir | |
parent | c3caa7f78808e405b7cdbcdf89c9d35a43d2c3eb (diff) | |
download | vim-git-0f7a3e1de6f71e8e1423fe594890d6aa7f94e132.tar.gz |
patch 8.2.5019: cannot get the first screen column of a characterv8.2.5019
Problem: Cannot get the first screen column of a character.
Solution: Let virtcol() optionally return a list. (closes #10482,
closes #7964)
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_functions.vim | 11 | ||||
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 17 |
2 files changed, 24 insertions, 4 deletions
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index 1a05a590f..af07a6424 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -2947,4 +2947,15 @@ func Test_exepath() endif endfunc +" Test for virtcol() +func Test_virtcol() + enew! + 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)) + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index 4f39ebb51..e83e320c7 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -4494,14 +4494,23 @@ def Test_values() enddef def Test_virtcol() - v9.CheckDefAndScriptFailure(['virtcol(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1222: String or List required for argument 1']) - v9.CheckDefExecAndScriptFailure(['virtcol("")'], 'E1209: Invalid value for a line number') + v9.CheckDefAndScriptFailure(['virtcol(1.1)'], [ + 'E1013: Argument 1: type mismatch, expected string but got float', + 'E1222: String or List required for argument 1']) + v9.CheckDefAndScriptFailure(['virtcol(".", "a")'], [ + 'E1013: Argument 2: type mismatch, expected bool but got string', + 'E1212: Bool required for argument 2']) + v9.CheckDefExecAndScriptFailure(['virtcol("")'], + 'E1209: Invalid value for a line number') new - setline(1, ['abcdefgh']) + setline(1, ['abcde和平fgh']) cursor(1, 4) assert_equal(4, virtcol('.')) + assert_equal([4, 4], virtcol('.', 1)) + cursor(1, 6) + assert_equal([6, 7], virtcol('.', 1)) assert_equal(4, virtcol([1, 4])) - assert_equal(9, virtcol([1, '$'])) + assert_equal(13, virtcol([1, '$'])) assert_equal(0, virtcol([10, '$'])) bw! enddef |