diff options
author | Daniel Zhang <wodesuck@gmail.com> | 2022-10-14 17:12:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-14 02:12:46 -0700 |
commit | 81986a7349da7b88abde459194078e9893e8ae8b (patch) | |
tree | ff0e1bf0d73426fbfa4d2474c3a00242715f4cee /test/functional/lua/vim_spec.lua | |
parent | 9931db2e3fa43ed02e1b0bc6f167ed5398fa6369 (diff) | |
download | rneovim-81986a7349da7b88abde459194078e9893e8ae8b.tar.gz rneovim-81986a7349da7b88abde459194078e9893e8ae8b.tar.bz2 rneovim-81986a7349da7b88abde459194078e9893e8ae8b.zip |
fix(lua): on_yank error with blockwise multibyte region #20162
Prevent out of range error when calling `str_byteindex`.
Use `vim.str_byteindex(bufline, #bufline)` to cacluate utf length of `bufline`.
fix #20161
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r-- | test/functional/lua/vim_spec.lua | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 47a0004183..f250a3ec93 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -2227,13 +2227,19 @@ describe('lua stdlib', function() eq(true, exec_lua[[return vim.g.test]]) end) - it('vim.region', function() - insert(helpers.dedent( [[ - text tααt tααt text - text tαxt txtα tex - text tαxt tαxt - ]])) - eq({5,15}, exec_lua[[ return vim.region(0,{1,5},{1,14},'v',true)[1] ]]) + describe('vim.region', function() + it('charwise', function() + insert(helpers.dedent( [[ + text tααt tααt text + text tαxt txtα tex + text tαxt tαxt + ]])) + eq({5,15}, exec_lua[[ return vim.region(0,{1,5},{1,14},'v',true)[1] ]]) + end) + it('blockwise', function() + insert([[αα]]) + eq({0,5}, exec_lua[[ return vim.region(0,{0,0},{0,4},'3',true)[0] ]]) + end) end) describe('vim.on_key', function() |