Skip to content

Commit 11eee43

Browse files
committed
fix(cache): keep ordering of topmods the same as in rtp
1 parent b23a5dc commit 11eee43

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lua/lazy/core/cache.lua

+6-4
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ M.stats = {
3737
}
3838
M.me = debug.getinfo(1, "S").source:sub(2)
3939
M.me = vim.fn.fnamemodify(M.me, ":p:h:h:h:h"):gsub("\\", "/")
40-
---@type table<string, table<string,string>>
41-
M.topmods = { lazy = { [M.me] = M.me } }
40+
---@type table<string, string[]>
41+
M.topmods = { lazy = { M.me } }
4242
---@type table<string, string[]>
4343
M.indexed = { [M.me] = { "lazy" } }
4444
M.indexed_unloaded = false
@@ -229,7 +229,9 @@ function M._index(path)
229229
end
230230
if topname then
231231
M.topmods[topname] = M.topmods[topname] or {}
232-
M.topmods[topname][path] = path
232+
if not vim.tbl_contains(M.topmods[topname], path) then
233+
table.insert(M.topmods[topname], path)
234+
end
233235
table.insert(M.indexed[path], topname)
234236
end
235237
end)
@@ -257,7 +259,7 @@ function M.find(modname)
257259

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

0 commit comments

Comments
 (0)