Skip to content

Commit

Permalink
fix(cache): keep ordering of topmods the same as in rtp
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jan 1, 2023
1 parent b23a5dc commit 11eee43
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lua/lazy/core/cache.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ M.stats = {
}
M.me = debug.getinfo(1, "S").source:sub(2)
M.me = vim.fn.fnamemodify(M.me, ":p:h:h:h:h"):gsub("\\", "/")
---@type table<string, table<string,string>>
M.topmods = { lazy = { [M.me] = M.me } }
---@type table<string, string[]>
M.topmods = { lazy = { M.me } }
---@type table<string, string[]>
M.indexed = { [M.me] = { "lazy" } }
M.indexed_unloaded = false
Expand Down Expand Up @@ -229,7 +229,9 @@ function M._index(path)
end
if topname then
M.topmods[topname] = M.topmods[topname] or {}
M.topmods[topname][path] = path
if not vim.tbl_contains(M.topmods[topname], path) then
table.insert(M.topmods[topname], path)
end
table.insert(M.indexed[path], topname)
end
end)
Expand Down Expand Up @@ -257,7 +259,7 @@ function M.find(modname)

-- check top-level mods to find the module
local function _find()
for _, toppath in pairs(M.topmods[topmod] or {}) do
for _, toppath in ipairs(M.topmods[topmod] or {}) do
for _, pattern in ipairs(patterns) do
local path = toppath .. "/lua/" .. basename .. pattern
M.stats.find.stat = M.stats.find.stat + 1
Expand Down

0 comments on commit 11eee43

Please sign in to comment.