summaryrefslogtreecommitdiff
path: root/src/list.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-06-16 11:34:42 +0200
committerBram Moolenaar <Bram@vim.org>2020-06-16 11:34:42 +0200
commit9af78769eeae0318e07aa8b6af4d6e2244481ca7 (patch)
tree995f0acd6a0098a714f8dbc5434e0b9d9701828d /src/list.c
parentc70222d12a2f8552273c0de48a3bf7138d649175 (diff)
downloadvim-git-9af78769eeae0318e07aa8b6af4d6e2244481ca7.tar.gz
patch 8.2.0987: Vim9: cannot assign to [var; var]v8.2.0987
Problem: Vim9: cannot assign to [var; var]. Solution: Assign rest of items to a list.
Diffstat (limited to 'src/list.c')
-rw-r--r--src/list.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/list.c b/src/list.c
index 675cf4283..130ab2525 100644
--- a/src/list.c
+++ b/src/list.c
@@ -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.