vim-patch:8.2.2658: :for cannot loop over a string

Problem:    :for cannot loop over a string.
Solution:   Accept a string argument and iterate over its characters.
74e54fcb44

v8.2.2659 is already ported.

N/A patches for version.c:

vim-patch:8.2.2736: Vim9: for loop over string is a bit slow

Problem:    Vim9: for loop over string is a bit slow.
Solution:   Avoid using strlen().
175a41c13f
This commit is contained in:
Sean Dewar
2022-01-01 07:27:46 +00:00
parent 92e92f02e7
commit 7002a3433b
3 changed files with 59 additions and 7 deletions

View File

@@ -1692,6 +1692,26 @@ func Test_function_defined_line()
call delete('Xtest.vim')
endfunc
func Test_for_over_string()
let res = ''
for c in 'aéc̀d'
let res ..= c .. '-'
endfor
call assert_equal('a-é-c̀-d-', res)
let res = ''
for c in ''
let res ..= c .. '-'
endfor
call assert_equal('', res)
let res = ''
for c in v:_null_string
let res ..= c .. '-'
endfor
call assert_equal('', res)
endfunc
"-------------------------------------------------------------------------------
" Modelines {{{1
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker