From dac14fb5db15c7f3c6a37470e03603cc4601ff60 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Wed, 28 Aug 2024 14:48:58 +0700 Subject: [PATCH] fix: lookup now returns deep copy (#74) --- lua/lz/n/handler/init.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/lz/n/handler/init.lua b/lua/lz/n/handler/init.lua index 3d683c8..44470ab 100644 --- a/lua/lz/n/handler/init.lua +++ b/lua/lz/n/handler/init.lua @@ -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