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.
This commit is contained in:
Jan Edmund Lazo
2021-04-08 22:40:02 -04:00
parent cfeaea0d3e
commit b35daa986f

View File

@@ -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)