summaryrefslogtreecommitdiffstats
path: root/src/list.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-20 03:56:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-20 03:56:56 +0000
commit75a9fa68f6cdd6769813a8c5e055bfb00a08c089 (patch)
treedaf1676b4e5ea491b7a370467a24b8181cc21827 /src/list.c
parentAdding upstream version 2:9.1.0377. (diff)
downloadvim-75a9fa68f6cdd6769813a8c5e055bfb00a08c089.tar.xz
vim-75a9fa68f6cdd6769813a8c5e055bfb00a08c089.zip
Adding upstream version 2:9.1.0496.upstream/2%9.1.0496
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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)