Skip to content

Commit

Permalink
fix(loader): add auto loaded module to package.loaded early to preven…
Browse files Browse the repository at this point in the history
…t require loops
  • Loading branch information
folke committed Jul 21, 2024
1 parent 9a374a0 commit 18d1c1b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lua/lazy/core/loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -552,15 +552,16 @@ function M.loader(modname)
end

if ret then
M.auto_load(modname, ret.modpath)
local mod = package.loaded[modname]
if type(mod) == "table" then
return function()
return mod
end
if type(mod) ~= "table" then
mod = loadfile(ret.modpath, nil, nil, ret.stat)()
end
package.loaded[modname] = mod
M.auto_load(modname, ret.modpath)
-- selene: allow(incorrect_standard_library_use)
return loadfile(ret.modpath, nil, nil, ret.stat)
return function()
return mod
end
end
end

Expand Down

2 comments on commit 18d1c1b

@Parsifa1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that this commit damaged part of my configuration related to luasnip, but I haven't been able to reproduce it in the smallest way for the time being. I will continue to try and find a way to give an issue.

Error detected while processing User Autocommands for "LuasnipSnippetsAdded"

@folke
Copy link
Owner Author

@folke folke commented on 18d1c1b Jul 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, and also cmp. Just reverted this.
Need to look into why this happened.

Please sign in to comment.