diff --git a/lua/neotest/lib/file/find.lua b/lua/neotest/lib/file/find.lua index ad56742a..2646db3c 100644 --- a/lua/neotest/lib/file/find.lua +++ b/lua/neotest/lib/file/find.lua @@ -21,11 +21,13 @@ function M.find(root, opts) local err, dir_handle = uv.fs_opendir(root, max_entries) assert(not err, err) while dir_handle or #dirs_to_scan > 0 do - if not dir_handle then + while not dir_handle and #dirs_to_scan > 0 do dir = table.remove(dirs_to_scan, 1) logger.debug("Scanning directory:", dir) err, dir_handle = uv.fs_opendir(root .. sep .. dir, max_entries) - assert(not err, err) + if err then + logger.error("Error opening directory:", dir, err) + end end local iter_dir = function() @@ -48,9 +50,9 @@ function M.find(root, opts) local name, path_type = entry.name, entry.type local rel_path = name and (dir == "" and name or (dir .. sep .. name)) if - path_type == "directory" - and name:sub(1, 1) ~= "." - and (not filter_dir or filter_dir(name, rel_path, root)) + path_type == "directory" + and name:sub(1, 1) ~= "." + and (not filter_dir or filter_dir(name, rel_path, root)) then dirs_to_scan[#dirs_to_scan + 1] = rel_path elseif path_type == "file" then