From c791c0ed7d7bbcdc06a58b79eb4625682c60964c Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 17 Jan 2023 14:35:21 +0100 Subject: [PATCH] fix: work-around for libuv issue where fs_scandir_next sometimes fails to return a file type --- lua/lazy/core/util.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua index 9a81d28..7411664 100644 --- a/lua/lazy/core/util.lua +++ b/lua/lazy/core/util.lua @@ -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