1
0
forked from aniani/vim

patch 8.2.2533: Vim9: cannot use a range with :unlet

Problem:    Vim9: cannot use a range with :unlet.
Solution:   Implement ISN_UNLETRANGE.
This commit is contained in:
Bram Moolenaar
2021-02-20 17:04:02 +01:00
parent ada1d870b4
commit 5b5ae29bd3
11 changed files with 231 additions and 38 deletions

View File

@@ -530,6 +530,26 @@ list_find_str(list_T *l, long idx)
return tv_get_string(&li->li_tv);
}
/*
* Like 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 *
list_find_index(list_T *l, long *idx)
{
listitem_T *li = list_find(l, *idx);
if (li == NULL)
{
if (*idx < 0)
{
*idx = 0;
li = list_find(l, *idx);
}
}
return li;
}
/*
* Locate "item" list "l" and return its index.
* Returns -1 when "item" is not in the list.