mirror of https://github.com/folke/lazy.nvim.git
fix: work-around for libuv issue where fs_scandir_next sometimes fails to return a file type
This commit is contained in:
parent
1b2a6f631c
commit
c791c0ed7d
|
@ -175,13 +175,16 @@ function M.ls(path, fn)
|
||||||
local handle = vim.loop.fs_scandir(path)
|
local handle = vim.loop.fs_scandir(path)
|
||||||
while handle do
|
while handle do
|
||||||
local name, t = vim.loop.fs_scandir_next(handle)
|
local name, t = vim.loop.fs_scandir_next(handle)
|
||||||
-- HACK: assume type is a file if no type returned
|
|
||||||
-- see https://github.com/folke/lazy.nvim/issues/306
|
|
||||||
t = t or "file"
|
|
||||||
if not name then
|
if not name then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
if fn(path .. "/" .. name, name, t) == false then
|
|
||||||
|
local fname = path .. "/" .. name
|
||||||
|
|
||||||
|
-- HACK: type is not always returned due to a bug in luv,
|
||||||
|
-- so fecth it with fs_stat instead when needed.
|
||||||
|
-- see https://github.com/folke/lazy.nvim/issues/306
|
||||||
|
if fn(fname, name, t or vim.loop.fs_stat(fname).type) == false then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue