mirror of
https://github.com/vim/vim.git
synced 2025-10-03 05:14:07 -04:00
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.
This commit is contained in:
@@ -7484,6 +7484,26 @@ func Test_trinary_expression()
|
||||
call assert_equal(v:false, eval(string(v:false)))
|
||||
endfunction
|
||||
|
||||
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 test_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