fix(cache): use cached chunk when specs are loading for valid plugins

This commit is contained in:
Folke Lemaitre 2023-01-11 23:11:38 +01:00
parent e1cd9cd0ad
commit 07fd7adb34
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 3 additions and 2 deletions

View File

@ -77,12 +77,13 @@ function M.check_autoload(modname, modpath)
-- only needed when the plugin mod has been loaded -- only needed when the plugin mod has been loaded
---@type LazyCorePlugin ---@type LazyCorePlugin
local Plugin = package.loaded["lazy.core.plugin"] local Plugin = package.loaded["lazy.core.plugin"]
if Plugin and not Plugin.loading then if Plugin then
local plugin = Plugin.find(modpath) local plugin = Plugin.find(modpath)
if plugin and modpath:find(plugin.dir, 1, true) == 1 then if plugin and modpath:find(plugin.dir, 1, true) == 1 then
-- we're not interested in loader time, so calculate delta here -- we're not interested in loader time, so calculate delta here
M.stats.autoload.time = M.stats.autoload.time + uv.hrtime() - start 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 if plugin.module == false then
error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false") error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false")
end end