fix: avoid errors occurred by async.util.join (#244)

This commit is contained in:
JINNOUCHI Yasushi 2024-08-18 22:33:26 +09:00 committed by GitHub
parent a7ebbb485d
commit ee2af42d5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -116,14 +116,17 @@ end
---@async
---@return string[]
function Database:unlinked_entries()
return vim.tbl_flatten(async.util.join(vim.tbl_map(function(path)
-- HACK: async.util.join() does not work with empty table. So when the table
-- has no entries, return early.
local async_fns = vim.tbl_map(function(path)
return function()
local err, realpath = async.uv.fs_realpath(path)
if err or not realpath or realpath ~= path or fs.is_ignored(realpath) then
return path
end
end
end, vim.tbl_keys(self.tbl.records))))
end, vim.tbl_keys(self.tbl.records))
return #async_fns > 0 and vim.tbl_flatten(async.util.join(async_fns)) or {}
end
---@async