diff src/list.c @ 20871:65d9189d4dca v8.2.0987

patch 8.2.0987: Vim9: cannot assign to [var; var] Commit: https://github.com/vim/vim/commit/9af78769eeae0318e07aa8b6af4d6e2244481ca7 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 16 11:34:42 2020 +0200 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.
author Bram Moolenaar <Bram@vim.org>
date Tue, 16 Jun 2020 11:45:04 +0200
parents b366a0fe8296
children 7ee565134d4a
line wrap: on
line diff
--- a/src/list.c
+++ b/src/list.c
@@ -868,6 +868,26 @@ list_concat(list_T *l1, list_T *l2, typv
     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.