From 07fd7adb3427ac510c33de308cd5dfcc6ba701b6 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Jan 2023 23:11:38 +0100 Subject: [PATCH] fix(cache): use cached chunk when specs are loading for valid plugins --- lua/lazy/core/cache.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua index 5bd370a..bad46ab 100644 --- a/lua/lazy/core/cache.lua +++ b/lua/lazy/core/cache.lua @@ -77,12 +77,13 @@ function M.check_autoload(modname, modpath) -- only needed when the plugin mod has been loaded ---@type LazyCorePlugin local Plugin = package.loaded["lazy.core.plugin"] - if Plugin and not Plugin.loading then + if Plugin then local plugin = Plugin.find(modpath) if plugin and modpath:find(plugin.dir, 1, true) == 1 then -- we're not interested in loader time, so calculate delta here M.stats.autoload.time = M.stats.autoload.time + uv.hrtime() - start - if not plugin._.loaded then + -- don't load if we're loading specs or if the plugin is already loaded + if not (Plugin.loading or plugin._.loaded) then if plugin.module == false then error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false") end