fix(keys): only delete key handler mappings once

This commit is contained in:
Folke Lemaitre 2022-12-25 16:17:36 +01:00
parent 7421e70c08
commit 9837d5be7e
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 8 additions and 2 deletions

View File

@ -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)