1
0
forked from aniani/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.
This commit is contained in:
Bram Moolenaar
2020-06-16 11:34:42 +02:00
parent c70222d12a
commit 9af78769ee
8 changed files with 161 additions and 17 deletions

View File

@@ -868,6 +868,26 @@ list_concat(list_T *l1, list_T *l2, typval_T *tv)
return list_extend(l, l2, NULL);
}
list_T *
list_slice(list_T *ol, long n1, long n2)
{
listitem_T *item;
list_T *l = list_alloc();
if (l == NULL)
return NULL;
for (item = list_find(ol, n1); n1 <= n2; ++n1)
{
if (list_append_tv(l, &item->li_tv) == FAIL)
{
list_free(l);
return NULL;
}
item = item->li_next;
}
return l;
}
/*
* Make a copy of list "orig". Shallow if "deep" is FALSE.
* The refcount of the new list is set to 1.