Skip to content

Commit

Permalink
fix: never overwrite actual keymaps with group names
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jul 14, 2023
1 parent d871f2b commit f61da3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lua/which-key/tree.lua
Expand Up @@ -91,7 +91,15 @@ function Tree:add(mapping, opts)
self.nodes[node_key] = node
end
end
node.mapping = vim.tbl_deep_extend("force", node.mapping or {}, mapping)
if node.mapping and node.mapping.group and not mapping.group then
node.mapping = mapping
node.children = {}
elseif node.mapping and not node.mapping.group and mapping.group then
return node
else
node.mapping = vim.tbl_deep_extend("force", node.mapping or {}, mapping)
end

return node
end

Expand Down
2 changes: 1 addition & 1 deletion lua/which-key/view.lua
Expand Up @@ -282,7 +282,7 @@ function M.on_keys(opts)
local results = Keys.get_mappings(M.mode, M.keys, buf)

--- Check for an exact match. Feedkeys with remap
if results.mapping and not results.mapping.group and #results.mappings == 0 then
if results.mapping and not results.mapping.group then
M.hide()
if results.mapping.fn then
results.mapping.fn()
Expand Down

0 comments on commit f61da3a

Please sign in to comment.