0
0
mirror of https://github.com/vim/vim.git synced 2025-10-03 05:14:07 -04:00

patch 8.2.1461: Vim9: string indexes are counted in bytes

Problem:    Vim9: string indexes are counted in bytes.
Solution:   Use character indexes. (closes #6574)
This commit is contained in:
Bram Moolenaar
2020-08-15 18:39:05 +02:00
parent 451c2e3536
commit e3c37d8ebf
6 changed files with 78 additions and 24 deletions

View File

@@ -2075,12 +2075,28 @@ def Test_expr7_trailing()
enddef
def Test_expr7_subscript()
let text = 'abcdef'
assert_equal('', text[-1])
assert_equal('a', text[0])
assert_equal('e', text[4])
assert_equal('f', text[5])
assert_equal('', text[6])
let lines =<< trim END
let text = 'abcdef'
assert_equal('', text[-1])
assert_equal('a', text[0])
assert_equal('e', text[4])
assert_equal('f', text[5])
assert_equal('', text[6])
text = 'ábçdëf'
assert_equal('', text[-999])
assert_equal('', text[-1])
assert_equal('á', text[0])
assert_equal('b', text[1])
assert_equal('ç', text[2])
assert_equal('d', text[3])
assert_equal('ë', text[4])
assert_equal('f', text[5])
assert_equal('', text[6])
assert_equal('', text[999])
END
CheckDefSuccess(lines)
CheckScriptSuccess(['vim9script'] + lines)
enddef
def Test_expr7_subscript_linebreak()