From 6b37927be9e0166ddb4445023904345d88045497 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 6 Oct 2023 19:42:19 +0200 Subject: [PATCH] fix(event): prevent loading event handler more than once in some cases --- lua/lazy/core/handler/event.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/lazy/core/handler/event.lua b/lua/lazy/core/handler/event.lua index 62d3ea3..8b40d9a 100644 --- a/lua/lazy/core/handler/event.lua +++ b/lua/lazy/core/handler/event.lua @@ -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