Skip to content

Commit d65a3d6

Browse files
committedJun 3, 2023
fix(keys): replace term codes to calculate ids
1 parent 9223c1a commit d65a3d6

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed
 

‎lua/lazy/core/handler/keys.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function M.parse(value)
1919
local ret = vim.deepcopy(value)
2020
ret = type(ret) == "string" and { ret } or ret --[[@as LazyKeys]]
2121
ret.mode = ret.mode or "n"
22-
ret.id = (ret[1] or "")
22+
ret.id = vim.api.nvim_replace_termcodes(ret[1] or "", true, true, true)
2323
if ret.mode then
2424
local mode = ret.mode
2525
if type(mode) == "table" then

‎tests/handlers/keys_spec.lua

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
local Keys = require("lazy.core.handler.keys")
2+
3+
describe("keys", function()
4+
it("parses ids correctly", function()
5+
local tests = {
6+
{ "<C-/>", "<c-/>", true },
7+
{ "<C-h>", "<c-H>", true },
8+
{ "<C-h>k", "<c-H>K", false },
9+
}
10+
for _, test in ipairs(tests) do
11+
if test[3] then
12+
assert.same(Keys.parse(test[1]).id, Keys.parse(test[2]).id)
13+
else
14+
assert.is_not.same(Keys.parse(test[1]).id, Keys.parse(test[2]).id)
15+
end
16+
end
17+
end)
18+
end)

0 commit comments

Comments
 (0)
Please sign in to comment.