Skip to content

Commit

Permalink
fix(hacks): schedule fixing cmp. Fixes #910
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jul 21, 2024
1 parent 1df01e4 commit b7515c0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lua/noice/util/hacks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,20 @@ end

---@param fn fun(mod)
function M.on_module(module, fn)
if package.loaded[module] then
return fn(package.loaded[module])
local on = vim.schedule_wrap(function()
fn(package.loaded[module])
end)
if package.loaded[module] ~= nil then
return on()
end

package.preload[module] = function()
package.preload[module] = nil
for _, loader in pairs(package.loaders) do
for _, loader in ipairs(package.loaders) do
local ret = loader(module)
if type(ret) == "function" then
local mod = ret()
fn(mod)
on()
return mod
end
end
Expand Down

0 comments on commit b7515c0

Please sign in to comment.