Mercurial > vim
comparison src/vim9execute.c @ 25776:f31cf0388eab v8.2.3423
patch 8.2.3423: Vim9: list += list creates a new list in :def function
Commit: https://github.com/vim/vim/commit/07802044b90b2cbcc64b2dfe235f019d7c37589c
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Sep 9 23:01:14 2021 +0200
patch 8.2.3423: Vim9: list += list creates a new list in :def function
Problem: Vim9: list += list creates a new list in :def function.
Solution: Append to the existing list.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 09 Sep 2021 23:15:04 +0200 |
parents | 154663508d9b |
children | fe8d153cb268 |
comparison
equal
deleted
inserted
replaced
25775:90bcb4296e14 | 25776:f31cf0388eab |
---|---|
3675 typval_T *tv1 = STACK_TV_BOT(-2); | 3675 typval_T *tv1 = STACK_TV_BOT(-2); |
3676 typval_T *tv2 = STACK_TV_BOT(-1); | 3676 typval_T *tv2 = STACK_TV_BOT(-1); |
3677 | 3677 |
3678 // add two lists or blobs | 3678 // add two lists or blobs |
3679 if (iptr->isn_type == ISN_ADDLIST) | 3679 if (iptr->isn_type == ISN_ADDLIST) |
3680 eval_addlist(tv1, tv2); | 3680 { |
3681 if (iptr->isn_arg.op.op_type == EXPR_APPEND | |
3682 && tv1->vval.v_list != NULL) | |
3683 list_extend(tv1->vval.v_list, tv2->vval.v_list, | |
3684 NULL); | |
3685 else | |
3686 eval_addlist(tv1, tv2); | |
3687 } | |
3681 else | 3688 else |
3682 eval_addblob(tv1, tv2); | 3689 eval_addblob(tv1, tv2); |
3683 clear_tv(tv2); | 3690 clear_tv(tv2); |
3684 --ectx->ec_stack.ga_len; | 3691 --ectx->ec_stack.ga_len; |
3685 } | 3692 } |