mirror of https://github.com/folke/lazy.nvim.git
fix: always recaclulate hash when loading a module
This commit is contained in:
parent
04dea38794
commit
cfc39330dc
|
@ -17,13 +17,12 @@ function M.load(modname, modpath)
|
||||||
---@type (string|fun())?
|
---@type (string|fun())?
|
||||||
local chunk = Cache.get(modname)
|
local chunk = Cache.get(modname)
|
||||||
|
|
||||||
if chunk then
|
|
||||||
local hash = Cache.hash(modpath)
|
local hash = Cache.hash(modpath)
|
||||||
if hash ~= M.hashes[modname] then
|
if hash ~= M.hashes[modname] then
|
||||||
M.hashes[modname] = hash
|
M.hashes[modname] = hash
|
||||||
|
Cache.del(modname)
|
||||||
chunk = nil
|
chunk = nil
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if chunk then
|
if chunk then
|
||||||
chunk, err = loadstring(chunk --[[@as string]], "@" .. modpath)
|
chunk, err = loadstring(chunk --[[@as string]], "@" .. modpath)
|
||||||
|
@ -32,9 +31,8 @@ function M.load(modname, modpath)
|
||||||
vim.notify("loadfile(" .. modname .. ")")
|
vim.notify("loadfile(" .. modname .. ")")
|
||||||
end)
|
end)
|
||||||
chunk, err = loadfile(modpath)
|
chunk, err = loadfile(modpath)
|
||||||
if chunk then
|
if chunk and not err then
|
||||||
Cache.set(modname, string.dump(chunk))
|
Cache.set(modname, string.dump(chunk))
|
||||||
M.hashes[modname] = M.hashes[modname] or Cache.hash(modpath)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -56,7 +54,7 @@ function M.setup()
|
||||||
|
|
||||||
-- preload core modules
|
-- preload core modules
|
||||||
local root = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h:h")
|
local root = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h:h")
|
||||||
for _, name in ipairs({ "util", "config", "loader", "state" }) do
|
for _, name in ipairs({ "util", "config", "loader", "state", "plugin" }) do
|
||||||
local modname = "lazy.core." .. name
|
local modname = "lazy.core." .. name
|
||||||
---@diagnostic disable-next-line: no-unknown
|
---@diagnostic disable-next-line: no-unknown
|
||||||
package.preload[modname] = function()
|
package.preload[modname] = function()
|
||||||
|
|
Loading…
Reference in New Issue