Skip to content

Commit

Permalink
fix(keys): fix nested operators. See #600. Fixes #609
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 6, 2024
1 parent e89203e commit 25d5b9e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lua/which-key/keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ function M.setup()
end

function M.get_operator(prefix_i)
local ret = { i = nil, n = nil, len = nil }
for op_n, _ in pairs(Config.options.operators) do
local op_i = Util.t(op_n)
if prefix_i:sub(1, #op_i) == op_i then
return op_i, op_n
if prefix_i:sub(1, #op_i) == op_i and (ret.len == nil or #op_i > ret.len) then
ret = { i = op_i, n = op_n, len = #op_i }
end
end
return ret.i, ret.n
end

function M.process_motions(ret, mode, prefix_i, buf)
Expand Down

0 comments on commit 25d5b9e

Please sign in to comment.