mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
feat(lua): vim.tbl_contains supports general tables and predicates (#23040)
* feat(lua): vim.tbl_contains supports general tables and predicates Problem: `vim.tbl_contains` only works for list-like tables (integer keys without gaps) and primitive values (in particular, not for nested tables). Solution: Rename `vim.tbl_contains` to `vim.list_contains` and add new `vim.tbl_contains` that works for general tables and optionally allows `value` to be a predicate function that is checked for every key.
This commit is contained in:
@@ -17,14 +17,14 @@ P.take_until = function(targets, specials)
|
||||
table.insert(raw, '\\')
|
||||
new_pos = new_pos + 1
|
||||
c = string.sub(input, new_pos, new_pos)
|
||||
if not vim.tbl_contains(targets, c) and not vim.tbl_contains(specials, c) then
|
||||
if not vim.list_contains(targets, c) and not vim.list_contains(specials, c) then
|
||||
table.insert(esc, '\\')
|
||||
end
|
||||
table.insert(raw, c)
|
||||
table.insert(esc, c)
|
||||
new_pos = new_pos + 1
|
||||
else
|
||||
if vim.tbl_contains(targets, c) then
|
||||
if vim.list_contains(targets, c) then
|
||||
break
|
||||
end
|
||||
table.insert(raw, c)
|
||||
|
||||
Reference in New Issue
Block a user