aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/typval.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-06-12 15:38:53 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-06-12 17:20:55 +0800
commita0cb53eca7a04326dd857cf33fac1154aff7773a (patch)
tree73d0046d0cd7752b0503e60b5c55cd1f0b512bbc /src/nvim/eval/typval.c
parent551cc3a2a3e2ee180234910cbe2ef81bd37508de (diff)
downloadrneovim-a0cb53eca7a04326dd857cf33fac1154aff7773a.tar.gz
rneovim-a0cb53eca7a04326dd857cf33fac1154aff7773a.tar.bz2
rneovim-a0cb53eca7a04326dd857cf33fac1154aff7773a.zip
vim-patch:8.2.2533: Vim9: cannot use a range with :unlet
Problem: Vim9: cannot use a range with :unlet. Solution: Implement ISN_UNLETRANGE. https://github.com/vim/vim/commit/5b5ae29bd3d7b832b6f15320430f7f191e0abd1f Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/eval/typval.c')
-rw-r--r--src/nvim/eval/typval.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index a392d441cf..9e697d6144 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -1507,6 +1507,21 @@ const char *tv_list_find_str(list_T *const l, const int n)
return tv_get_string(TV_LIST_ITEM_TV(li));
}
+/// Like tv_list_find() but when a negative index is used that is not found use
+/// zero and set "idx" to zero. Used for first index of a range.
+listitem_T *tv_list_find_index(list_T *const l, long *const idx)
+ FUNC_ATTR_WARN_UNUSED_RESULT
+{
+ listitem_T *li = tv_list_find(l, (int)(*idx));
+ if (li == NULL) {
+ if (*idx < 0) {
+ *idx = 0;
+ li = tv_list_find(l, (int)(*idx));
+ }
+ }
+ return li;
+}
+
/// Locate item in a list and return its index
///
/// @param[in] l List to search.