Skip to content

Commit

Permalink
fix: work-around for libuv issue where fs_scandir_next sometimes fail…
Browse files Browse the repository at this point in the history
…s to return a file type
  • Loading branch information
folke committed Jan 17, 2023
1 parent 1b2a6f6 commit c791c0e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lua/lazy/core/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,16 @@ function M.ls(path, fn)
local handle = vim.loop.fs_scandir(path)
while handle do
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
break
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
end
end
Expand Down

0 comments on commit c791c0e

Please sign in to comment.