fix: flatten

This commit is contained in:
Folke Lemaitre 2024-07-07 00:28:06 +02:00
parent 099f30fafe
commit cdbd1f2da8
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
3 changed files with 16 additions and 2 deletions

View File

@ -98,7 +98,7 @@ function M.get_type(prop)
if vim.tbl_isempty(types) then
types = { "any" }
end
return vim.iter(types):flatten():join("|")
return table.concat(util.flatten(types), "|")
end
function M.process_object(name, prop)

View File

@ -118,7 +118,7 @@ function M.translate(props, nls_url)
desc = nls[desc:gsub("%%", "")] or desc
if type(desc) == "table" then
local lines = vim.tbl_values(desc)
lines = vim.iter(lines):flatten():totable()
lines = Util.flatten(lines)
table.sort(lines)
desc = table.concat(lines, "\n\n")
end

View File

@ -70,6 +70,20 @@ function M.on_config(opts)
end)
end
---@param t table
---@param ret? table
function M.flatten(t, ret)
ret = ret or {}
for _, v in pairs(t) do
if type(v) == "table" then
M.flatten(v, ret)
else
ret[#ret + 1] = v
end
end
return ret
end
---@param opts? { local: boolean, global: boolean, autocmd: boolean }
---@return string[]
function M.file_patterns(opts)