mirror of https://github.com/folke/lazy.nvim.git
Revert "fix(event): dont use autocmd pattern to detect event retriggering. Fixes #858"
This reverts commit bc89502357
.
This commit is contained in:
parent
27c12ff0a9
commit
ae25448d39
|
@ -28,11 +28,11 @@ function M:_add(value)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
Util.track({ [self.type] = value })
|
Util.track({ [self.type] = value })
|
||||||
local groups = M.get_augroups(event)
|
local groups = M.get_augroups(event, pattern)
|
||||||
-- load the plugins
|
-- load the plugins
|
||||||
Loader.load(self.active[value], { [self.type] = value })
|
Loader.load(self.active[value], { [self.type] = value })
|
||||||
-- check if any plugin created an event handler for this event and fire the group
|
-- check if any plugin created an event handler for this event and fire the group
|
||||||
self:trigger(event, groups)
|
self:trigger(event, pattern, groups)
|
||||||
Util.track()
|
Util.track()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -45,11 +45,12 @@ end
|
||||||
|
|
||||||
-- Get all augroups for the events
|
-- Get all augroups for the events
|
||||||
---@param event string
|
---@param event string
|
||||||
function M.get_augroups(event)
|
---@param pattern? string
|
||||||
|
function M.get_augroups(event, pattern)
|
||||||
local events = M.trigger_events[event] or { event }
|
local events = M.trigger_events[event] or { event }
|
||||||
---@type table<string,true>
|
---@type table<string,true>
|
||||||
local groups = {}
|
local groups = {}
|
||||||
for _, autocmd in ipairs(vim.api.nvim_get_autocmds({ event = events })) do
|
for _, autocmd in ipairs(vim.api.nvim_get_autocmds({ event = events, pattern = pattern })) do
|
||||||
if autocmd.group then
|
if autocmd.group then
|
||||||
groups[autocmd.group] = true
|
groups[autocmd.group] = true
|
||||||
end
|
end
|
||||||
|
@ -60,17 +61,18 @@ end
|
||||||
---@param event string|string[]
|
---@param event string|string[]
|
||||||
---@param pattern? string
|
---@param pattern? string
|
||||||
---@param groups table<string,true>
|
---@param groups table<string,true>
|
||||||
function M:trigger(event, groups)
|
function M:trigger(event, pattern, groups)
|
||||||
local events = M.trigger_events[event] or { event }
|
local events = M.trigger_events[event] or { event }
|
||||||
---@cast events string[]
|
---@cast events string[]
|
||||||
for _, e in ipairs(events) do
|
for _, e in ipairs(events) do
|
||||||
for _, autocmd in ipairs(vim.api.nvim_get_autocmds({ event = e })) do
|
for _, autocmd in ipairs(vim.api.nvim_get_autocmds({ event = e, pattern = pattern })) do
|
||||||
if autocmd.event == e and autocmd.group and not groups[autocmd.group] then
|
if autocmd.event == e and autocmd.group and not groups[autocmd.group] then
|
||||||
if Config.options.debug then
|
if Config.options.debug then
|
||||||
Util.info({
|
Util.info({
|
||||||
"# Firing Events",
|
"# Firing Events",
|
||||||
" - **group:** `" .. autocmd.group_name .. "`",
|
" - **group:** `" .. autocmd.group_name .. "`",
|
||||||
" - **event:** " .. autocmd.event,
|
" - **event:** " .. autocmd.event,
|
||||||
|
pattern and (" - **pattern:** " .. pattern),
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
Util.track({ event = autocmd.group_name })
|
Util.track({ event = autocmd.group_name })
|
||||||
|
|
Loading…
Reference in New Issue