diff --git a/lua/lazy/core/handler/keys.lua b/lua/lazy/core/handler/keys.lua index 73b10b7..cdf2243 100644 --- a/lua/lazy/core/handler/keys.lua +++ b/lua/lazy/core/handler/keys.lua @@ -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 diff --git a/tests/handlers/keys_spec.lua b/tests/handlers/keys_spec.lua new file mode 100644 index 0000000..6254db8 --- /dev/null +++ b/tests/handlers/keys_spec.lua @@ -0,0 +1,18 @@ +local Keys = require("lazy.core.handler.keys") + +describe("keys", function() + it("parses ids correctly", function() + local tests = { + { "", "", true }, + { "", "", true }, + { "k", "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)