mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
fix(util): ensure unique cache keys in LazyVim.memoize
This commit is contained in:
parent
7d30360df2
commit
00be797787
1 changed files with 3 additions and 1 deletions
|
|
@ -274,8 +274,10 @@ local cache = {} ---@type table<string, any>
|
|||
---@param fn T
|
||||
---@return T
|
||||
function M.memoize(fn)
|
||||
local info = debug.getinfo(fn, "S")
|
||||
local keyprefix = info.source .. ":" .. info.linedefined .. ":"
|
||||
return function(...)
|
||||
local key = vim.inspect({ ... })
|
||||
local key = keyprefix .. vim.inspect({ ... })
|
||||
if cache[key] == nil then
|
||||
cache[key] = fn(...)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue