fix(event): prevent loading event handler more than once in some cases

This commit is contained in:
Folke Lemaitre 2023-10-06 19:42:19 +02:00
parent 25f6009087
commit 6b37927be9
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 3 additions and 1 deletions

View File

@ -15,14 +15,16 @@ function M:_add(value)
---@type string?, string?
local event, pattern = event_spec:match("^(%w+)%s+(.*)$")
event = event or event_spec
local done = false
vim.api.nvim_create_autocmd(event, {
group = self.group,
once = true,
pattern = pattern,
callback = function(ev)
if not self.active[value] then
if done or not self.active[value] then
return
end
done = true
Util.track({ [self.type] = value })
local groups = M.get_augroups(ev.event, pattern)
-- load the plugins