mirror of
https://github.com/neovim/neovim.git
synced 2026-01-06 11:27:26 +10: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:
@@ -26,7 +26,7 @@ end
|
||||
|
||||
function M.properties.charset(bufnr, val)
|
||||
assert(
|
||||
vim.tbl_contains({ 'utf-8', 'utf-8-bom', 'latin1', 'utf-16be', 'utf-16le' }, val),
|
||||
vim.list_contains({ 'utf-8', 'utf-8-bom', 'latin1', 'utf-16be', 'utf-16le' }, val),
|
||||
'charset must be one of "utf-8", "utf-8-bom", "latin1", "utf-16be", or "utf-16le"'
|
||||
)
|
||||
if val == 'utf-8' or val == 'utf-8-bom' then
|
||||
|
||||
Reference in New Issue
Block a user