summaryrefslogtreecommitdiffstats
path: root/src/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/list.c')
-rw-r--r--src/list.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/list.c b/src/list.c
index e9f1ae3..9479b4b 100644
--- a/src/list.c
+++ b/src/list.c
@@ -3194,4 +3194,28 @@ f_reduce(typval_T *argvars, typval_T *rettv)
blob_reduce(argvars, &argvars[1], rettv);
}
+/*
+ * slice() function
+ */
+ void
+f_slice(typval_T *argvars, typval_T *rettv)
+{
+ if (in_vim9script()
+ && ((argvars[0].v_type != VAR_STRING
+ && argvars[0].v_type != VAR_LIST
+ && argvars[0].v_type != VAR_BLOB
+ && check_for_list_arg(argvars, 0) == FAIL)
+ || check_for_number_arg(argvars, 1) == FAIL
+ || check_for_opt_number_arg(argvars, 2) == FAIL))
+ return;
+
+ if (check_can_index(&argvars[0], TRUE, FALSE) != OK)
+ return;
+
+ copy_tv(argvars, rettv);
+ eval_index_inner(rettv, TRUE, argvars + 1,
+ argvars[2].v_type == VAR_UNKNOWN ? NULL : argvars + 2,
+ TRUE, NULL, 0, FALSE);
+}
+
#endif // defined(FEAT_EVAL)