mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.0987: Vim9: cannot assign to [var; var]
Problem: Vim9: cannot assign to [var; var].
Solution: Assign rest of items to a list.
9af78769ee
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
24d4a82569
commit
1659cd15be
@ -3683,9 +3683,6 @@ static int eval_index(char **arg, typval_T *rettv, evalarg_T *const evalarg, boo
|
||||
n1 = (int)len;
|
||||
}
|
||||
if (range) {
|
||||
list_T *l;
|
||||
listitem_T *item;
|
||||
|
||||
if (n2 < 0) {
|
||||
n2 = (int)len + n2;
|
||||
} else if (n2 >= len) {
|
||||
@ -3694,12 +3691,7 @@ static int eval_index(char **arg, typval_T *rettv, evalarg_T *const evalarg, boo
|
||||
if (!empty2 && (n2 < 0 || n2 + 1 < n1)) {
|
||||
n2 = -1;
|
||||
}
|
||||
l = tv_list_alloc(n2 - n1 + 1);
|
||||
item = tv_list_find(rettv->vval.v_list, n1);
|
||||
while (n1++ <= n2) {
|
||||
tv_list_append_tv(l, TV_LIST_ITEM_TV(item));
|
||||
item = TV_LIST_ITEM_NEXT(rettv->vval.v_list, item);
|
||||
}
|
||||
list_T *l = tv_list_slice(rettv->vval.v_list, n1, n2);
|
||||
tv_clear(rettv);
|
||||
tv_list_set_ret(rettv, l);
|
||||
} else {
|
||||
|
@ -765,6 +765,17 @@ int tv_list_concat(list_T *const l1, list_T *const l2, typval_T *const tv)
|
||||
return OK;
|
||||
}
|
||||
|
||||
list_T *tv_list_slice(list_T *ol, int n1, int n2)
|
||||
{
|
||||
list_T *l = tv_list_alloc(n2 - n1 + 1);
|
||||
listitem_T *item = tv_list_find(ol, n1);
|
||||
for (; n1 <= n2; n1++) {
|
||||
tv_list_append_tv(l, TV_LIST_ITEM_TV(item));
|
||||
item = TV_LIST_ITEM_NEXT(rettv->vval.v_list, item);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
char *s;
|
||||
char *tofree;
|
||||
|
Loading…
Reference in New Issue
Block a user