fix: lookup now returns deep copy (#74)

This commit is contained in:
Marc Jakobi
2024-08-28 14:48:58 +07:00
committed by GitHub
parent 8b6af27dc6
commit dac14fb5db

View File

@@ -10,7 +10,7 @@ local handlers = {
---@param name string
---@param opts? lz.n.lookup.Opts
---@return lz.n.Plugin?
---@return lz.n.Plugin | nil
function M.lookup(name, opts)
---@type string | string[] | nil
local filter = opts and vim.tbl_get(opts, "filter")
@@ -26,7 +26,8 @@ function M.lookup(name, opts)
:totable()
or vim.tbl_values(handlers)
---@cast filter string[] | nil
return vim
---@type lz.n.Plugin | nil
local result = vim
.iter(handler_list)
---@param handler lz.n.Handler
:map(function(handler)
@@ -36,6 +37,7 @@ function M.lookup(name, opts)
:find(function(result)
return result ~= nil
end)
return result and vim.deepcopy(result)
end
---@param spec lz.n.PluginSpec