Browse Source

vim-patch:8.2.2738: extending a list with itself can give wrong result

Problem:    Extending a list with itself can give wrong result.
Solution:   Remember the item before where the insertion happens and skip to
            after the already inserted items. (closes vim/vim#1112)
dcae51facc

Originated from Neovim commit 7ceebacb3f.
pull/14326/head
Jan Edmund Lazo 1 month ago
parent
commit
b35daa986f
No known key found for this signature in database GPG Key ID: 64915E6E9F735B15
  1. 17
      src/nvim/testdir/test_listdict.vim

17
src/nvim/testdir/test_listdict.vim

@ -718,6 +718,23 @@ func Test_listdict_extend()
call assert_fails("call extend([1, 2], 1)", 'E712:')
call assert_fails("call extend([1, 2], {})", 'E712:')
" Extend g: dictionary with an invalid variable name
call assert_fails("call extend(g:, {'-!' : 10})", 'E461:')
" Extend a list with itself.
let l = [1, 5, 7]
call extend(l, l, 0)
call assert_equal([1, 5, 7, 1, 5, 7], l)
let l = [1, 5, 7]
call extend(l, l, 1)
call assert_equal([1, 1, 5, 7, 5, 7], l)
let l = [1, 5, 7]
call extend(l, l, 2)
call assert_equal([1, 5, 1, 5, 7, 7], l)
let l = [1, 5, 7]
call extend(l, l, 3)
call assert_equal([1, 5, 7, 1, 5, 7], l)
endfunc
func s:check_scope_dict(x, fixed)

Loading…
Cancel
Save