Skip to content

Commit 9837d5b

Browse files
committed
fix(keys): only delete key handler mappings once
1 parent 7421e70 commit 9837d5b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lua/lazy/core/handler/keys.lua

+8-2
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,15 @@ function M:_add(value)
6868
local opts = M.opts(keys)
6969
opts.noremap = true
7070
vim.keymap.set(keys.mode, lhs, function()
71-
pcall(vim.keymap.del, keys.mode, lhs)
71+
local key = self:key(value)
72+
local plugins = self.active[key]
73+
74+
-- always delete the mapping immediately to prevent recursive mappings
75+
self:_del(value)
76+
self.active[key] = nil
77+
7278
Util.track({ keys = lhs })
73-
Loader.load(self.active[self:key(value)], { keys = lhs })
79+
Loader.load(plugins, { keys = lhs })
7480
M.retrigger(lhs)
7581
Util.track()
7682
end, opts)

0 commit comments

Comments
 (0)