fix(handlers): allow overriding handler values

This commit is contained in:
Folke Lemaitre 2023-01-11 13:43:57 +01:00
parent 3b44c3c14a
commit 74bc61ab97
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 11 additions and 0 deletions

View File

@ -77,8 +77,13 @@ end
---@param plugin LazyPlugin ---@param plugin LazyPlugin
function M:add(plugin) function M:add(plugin)
local values = {}
for _, value in ipairs(plugin[self.type] or {}) do for _, value in ipairs(plugin[self.type] or {}) do
local key = self:key(value) local key = self:key(value)
values[key] = value
end
for key, value in pairs(values) do
if not self.active[key] then if not self.active[key] then
self.active[key] = {} self.active[key] = {}
self:_add(value) self:_add(value)
@ -89,7 +94,13 @@ end
---@param plugin LazyPlugin ---@param plugin LazyPlugin
function M:del(plugin) function M:del(plugin)
local values = {}
for _, value in ipairs(plugin[self.type] or {}) do for _, value in ipairs(plugin[self.type] or {}) do
local key = self:key(value)
values[key] = value
end
for key, value in pairs(values) do
local key = self:key(value) local key = self:key(value)
if self.active[key] and self.active[key][plugin.name] then if self.active[key] and self.active[key][plugin.name] then
self.active[key][plugin.name] = nil self.active[key][plugin.name] = nil