Mercurial > vim
diff src/list.c @ 23982:9fcd71d0db89 v8.2.2533
patch 8.2.2533: Vim9: cannot use a range with :unlet
Commit: https://github.com/vim/vim/commit/5b5ae29bd3d7b832b6f15320430f7f191e0abd1f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 20 17:04:02 2021 +0100
patch 8.2.2533: Vim9: cannot use a range with :unlet
Problem: Vim9: cannot use a range with :unlet.
Solution: Implement ISN_UNLETRANGE.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 20 Feb 2021 17:15:03 +0100 |
parents | 4b417b776b95 |
children | 06da0685077b |
line wrap: on
line diff
--- a/src/list.c +++ b/src/list.c @@ -531,6 +531,26 @@ list_find_str(list_T *l, long idx) } /* + * 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. */