mirror of
https://github.com/neovim/neovim.git
synced 2025-10-09 19:36:40 +00:00
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user