Skip to content

Commit

Permalink
fix(keys): only delete key handler mappings once
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 25, 2022
1 parent 7421e70 commit 9837d5b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lua/lazy/core/handler/keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,15 @@ function M:_add(value)
local opts = M.opts(keys)
opts.noremap = true
vim.keymap.set(keys.mode, lhs, function()
pcall(vim.keymap.del, keys.mode, lhs)
local key = self:key(value)
local plugins = self.active[key]

-- always delete the mapping immediately to prevent recursive mappings
self:_del(value)
self.active[key] = nil

Util.track({ keys = lhs })
Loader.load(self.active[self:key(value)], { keys = lhs })
Loader.load(plugins, { keys = lhs })
M.retrigger(lhs)
Util.track()
end, opts)
Expand Down

0 comments on commit 9837d5b

Please sign in to comment.