Skip to content

Commit cfc3933

Browse files
committed
fix: always recaclulate hash when loading a module
1 parent 04dea38 commit cfc3933

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

lua/lazy/core/module.lua

+7-9
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ function M.load(modname, modpath)
1717
---@type (string|fun())?
1818
local chunk = Cache.get(modname)
1919

20-
if chunk then
21-
local hash = Cache.hash(modpath)
22-
if hash ~= M.hashes[modname] then
23-
M.hashes[modname] = hash
24-
chunk = nil
25-
end
20+
local hash = Cache.hash(modpath)
21+
if hash ~= M.hashes[modname] then
22+
M.hashes[modname] = hash
23+
Cache.del(modname)
24+
chunk = nil
2625
end
2726

2827
if chunk then
@@ -32,9 +31,8 @@ function M.load(modname, modpath)
3231
vim.notify("loadfile(" .. modname .. ")")
3332
end)
3433
chunk, err = loadfile(modpath)
35-
if chunk then
34+
if chunk and not err then
3635
Cache.set(modname, string.dump(chunk))
37-
M.hashes[modname] = M.hashes[modname] or Cache.hash(modpath)
3836
end
3937
end
4038

@@ -56,7 +54,7 @@ function M.setup()
5654

5755
-- preload core modules
5856
local root = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h:h")
59-
for _, name in ipairs({ "util", "config", "loader", "state" }) do
57+
for _, name in ipairs({ "util", "config", "loader", "state", "plugin" }) do
6058
local modname = "lazy.core." .. name
6159
---@diagnostic disable-next-line: no-unknown
6260
package.preload[modname] = function()

0 commit comments

Comments
 (0)