Skip to content

Commit

Permalink
fix(keys): replace term codes to calculate ids
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 3, 2023
1 parent 9223c1a commit d65a3d6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lua/lazy/core/handler/keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function M.parse(value)
local ret = vim.deepcopy(value)
ret = type(ret) == "string" and { ret } or ret --[[@as LazyKeys]]
ret.mode = ret.mode or "n"
ret.id = (ret[1] or "")
ret.id = vim.api.nvim_replace_termcodes(ret[1] or "", true, true, true)
if ret.mode then
local mode = ret.mode
if type(mode) == "table" then
Expand Down
18 changes: 18 additions & 0 deletions tests/handlers/keys_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
local Keys = require("lazy.core.handler.keys")

describe("keys", function()
it("parses ids correctly", function()
local tests = {
{ "<C-/>", "<c-/>", true },
{ "<C-h>", "<c-H>", true },
{ "<C-h>k", "<c-H>K", false },
}
for _, test in ipairs(tests) do
if test[3] then
assert.same(Keys.parse(test[1]).id, Keys.parse(test[2]).id)
else
assert.is_not.same(Keys.parse(test[1]).id, Keys.parse(test[2]).id)
end
end
end)
end)

0 comments on commit d65a3d6

Please sign in to comment.