aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-11-05 17:16:49 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-11-05 18:06:00 +0800
commit781616bee5e319fdfa034484c026222b50926ebf (patch)
tree8decb6167be762e9bd93132c5e47168f3b56f9ca /src/nvim/testdir
parent451850920b361059ba99bbde4b90b7730327eebb (diff)
downloadrneovim-781616bee5e319fdfa034484c026222b50926ebf.tar.gz
rneovim-781616bee5e319fdfa034484c026222b50926ebf.tar.bz2
rneovim-781616bee5e319fdfa034484c026222b50926ebf.zip
vim-patch:8.2.2606: strchars() defaults to counting composing characters
Problem: strchars() defaults to counting composing characters. Solution: Add strcharlen() which ignores composing characters. https://github.com/vim/vim/commit/70ce8a1561c5396e4c4381f76a005cbb97646f80 Use docs from latest Vim instead. Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_utf8.vim9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/nvim/testdir/test_utf8.vim b/src/nvim/testdir/test_utf8.vim
index 3d29d38231..aa3b02b575 100644
--- a/src/nvim/testdir/test_utf8.vim
+++ b/src/nvim/testdir/test_utf8.vim
@@ -12,7 +12,7 @@ func Test_visual_block_insert()
bwipeout!
endfunc
-" Test for built-in function strchars()
+" Test for built-in functions strchars() and strcharlen()
func Test_strchars()
let inp = ["a", "あいa", "A\u20dd", "A\u20dd\u20dd", "\u20dd"]
let exp = [[1, 1, 1], [3, 3, 3], [2, 2, 1], [3, 3, 1], [1, 1, 1]]
@@ -21,6 +21,13 @@ func Test_strchars()
call assert_equal(exp[i][1], inp[i]->strchars(0))
call assert_equal(exp[i][2], strchars(inp[i], 1))
endfor
+
+ let exp = [1, 3, 1, 1, 1]
+ for i in range(len(inp))
+ call assert_equal(exp[i], inp[i]->strcharlen())
+ call assert_equal(exp[i], strcharlen(inp[i]))
+ endfor
+
call assert_fails("let v=strchars('abc', [])", 'E745:')
call assert_fails("let v=strchars('abc', 2)", 'E1023:')
endfunc