From 53c9500c1dc95eb446e13e857a7d6a7642d859ab Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 8 Aug 2022 08:22:10 +0800 Subject: vim-patch:8.2.1535: it is not possible to specify cell widths of characters Problem: It is not possible to specify cell widths of characters. Solution: Add setcellwidths(). https://github.com/vim/vim/commit/08aac3c6192f0103cb87e280270a32b50e653be1 Co-Authored-By: delphinus --- src/nvim/testdir/test_utf8.vim | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_utf8.vim b/src/nvim/testdir/test_utf8.vim index 9b010a5dbc..c5dfd85e5e 100644 --- a/src/nvim/testdir/test_utf8.vim +++ b/src/nvim/testdir/test_utf8.vim @@ -140,6 +140,41 @@ func Test_list2str_str2list_latin1() call assert_equal(s, sres) endfunc +func Test_setcellwidths() + call setcellwidths([ + \ [0x1330, 0x1330, 2], + \ [0x1337, 0x1339, 2], + \ [9999, 10000, 1], + \]) + + call assert_equal(2, strwidth("\u1330")) + call assert_equal(1, strwidth("\u1336")) + call assert_equal(2, strwidth("\u1337")) + call assert_equal(2, strwidth("\u1339")) + call assert_equal(1, strwidth("\u133a")) + + call setcellwidths([]) + + call assert_fails('call setcellwidths(1)', 'E714:') + + call assert_fails('call setcellwidths([1, 2, 0])', 'E1109:') + + call assert_fails('call setcellwidths([[0x101]])', 'E1110:') + call assert_fails('call setcellwidths([[0x101, 0x102]])', 'E1110:') + call assert_fails('call setcellwidths([[0x101, 0x102, 1, 4]])', 'E1110:') + call assert_fails('call setcellwidths([["a"]])', 'E1110:') + + call assert_fails('call setcellwidths([[0x102, 0x101, 1]])', 'E1111:') + + call assert_fails('call setcellwidths([[0x101, 0x102, 0]])', 'E1112:') + call assert_fails('call setcellwidths([[0x101, 0x102, 3]])', 'E1112:') + + call assert_fails('call setcellwidths([[0x111, 0x122, 1], [0x115, 0x116, 2]])', 'E1113:') + call assert_fails('call setcellwidths([[0x111, 0x122, 1], [0x122, 0x123, 2]])', 'E1113:') + + call assert_fails('call setcellwidths([[0x33, 0x44, 2]])', 'E1114:') +endfunc + func Test_print_overlong() " Text with more composing characters than MB_MAXBYTES. new -- cgit From 967415d5277df25ee96d961ec0ab95ddfe01a611 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 8 Aug 2022 12:01:57 +0800 Subject: vim-patch:8.2.1537: memory acccess error when using setcellwidths() Problem: Memory acccess error when using setcellwidths(). Solution: Use array and pointers correctly. https://github.com/vim/vim/commit/b06a6d59d12dbd67d55b3c46f6e5547e9103c931 --- src/nvim/testdir/test_utf8.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_utf8.vim b/src/nvim/testdir/test_utf8.vim index c5dfd85e5e..882e9623f6 100644 --- a/src/nvim/testdir/test_utf8.vim +++ b/src/nvim/testdir/test_utf8.vim @@ -143,8 +143,8 @@ endfunc func Test_setcellwidths() call setcellwidths([ \ [0x1330, 0x1330, 2], - \ [0x1337, 0x1339, 2], \ [9999, 10000, 1], + \ [0x1337, 0x1339, 2], \]) call assert_equal(2, strwidth("\u1330")) -- cgit From 9fedb6fd783b9ac48239bc7574779118eec3729a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 8 Aug 2022 12:08:28 +0800 Subject: vim-patch:8.2.3545: setcellwidths() may make 'listchars' or 'fillchars' invalid Problem: setcellwidths() may make 'listchars' or 'fillchars' invalid. Solution: Check the value and give an error. (closes vim/vim#9024) https://github.com/vim/vim/commit/94358a1e6e640ca5ebeb295efdddd4e92b700673 Cherry-pick f_setcellwidths() change from patch 9.0.0036. Cherry-pick 'ambiwidth' docs update from runtime update 079ba76ae7a7. --- src/nvim/testdir/test_utf8.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_utf8.vim b/src/nvim/testdir/test_utf8.vim index 882e9623f6..ab3503c282 100644 --- a/src/nvim/testdir/test_utf8.vim +++ b/src/nvim/testdir/test_utf8.vim @@ -173,6 +173,16 @@ func Test_setcellwidths() call assert_fails('call setcellwidths([[0x111, 0x122, 1], [0x122, 0x123, 2]])', 'E1113:') call assert_fails('call setcellwidths([[0x33, 0x44, 2]])', 'E1114:') + + set listchars=tab:--\\u2192 + call assert_fails('call setcellwidths([[0x2192, 0x2192, 2]])', 'E834:') + + set fillchars=stl:\\u2501 + call assert_fails('call setcellwidths([[0x2501, 0x2501, 2]])', 'E835:') + + set listchars& + set fillchars& + call setcellwidths([]) endfunc func Test_print_overlong() -- cgit