diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-04-08 22:40:02 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-04-08 22:58:13 -0400 |
commit | b35daa986f06f00939ddcf225a5efc59c26c418b (patch) | |
tree | e7e65e5079b1c1bcb22fed9c1628f12f5d270543 | |
parent | cfeaea0d3eb3f13a6f3c59f8d270082d9d2ec3b1 (diff) | |
download | rneovim-b35daa986f06f00939ddcf225a5efc59c26c418b.tar.gz rneovim-b35daa986f06f00939ddcf225a5efc59c26c418b.tar.bz2 rneovim-b35daa986f06f00939ddcf225a5efc59c26c418b.zip |
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)
https://github.com/vim/vim/commit/dcae51facc4d6de1edd62f0242b40972be841103
Originated from Neovim commit 7ceebacb3fad49ba8321397cf839948caa55b3f5.
-rw-r--r-- | src/nvim/testdir/test_listdict.vim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_listdict.vim b/src/nvim/testdir/test_listdict.vim index f9410fb620..affb141a26 100644 --- a/src/nvim/testdir/test_listdict.vim +++ b/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) |