mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-03 18:28:38 +00:00
fix(win): duplicate keymap should take mode into account. Closes #559
This commit is contained in:
parent
f7d967c515
commit
097e68fc72
1 changed files with 15 additions and 8 deletions
|
@ -272,16 +272,23 @@ function M.new(opts)
|
|||
end
|
||||
---@cast spec snacks.win.Keys
|
||||
local lhs = vim.fn.keytrans(Snacks.util.keycode(spec[1] or ""))
|
||||
if done[lhs] then
|
||||
Snacks.notify.warn(
|
||||
("# Duplicate key mapping for `%s` (check case):\n```lua\n%s\n```\n```lua\n%s\n```"):format(
|
||||
lhs,
|
||||
vim.inspect(done[lhs]),
|
||||
vim.inspect(spec)
|
||||
local mode = type(spec.mode) == "table" and spec.mode or { spec.mode or "n" }
|
||||
---@cast mode string[]
|
||||
mode = #mode == 0 and { "n" } or mode
|
||||
for _, m in ipairs(mode) do
|
||||
local k = m .. ":" .. lhs
|
||||
if done[k] then
|
||||
Snacks.notify.warn(
|
||||
("# Duplicate key mapping for `%s` mode=%s (check case):\n```lua\n%s\n```\n```lua\n%s\n```"):format(
|
||||
lhs,
|
||||
m,
|
||||
vim.inspect(done[k]),
|
||||
vim.inspect(spec)
|
||||
)
|
||||
)
|
||||
)
|
||||
end
|
||||
done[k] = spec
|
||||
end
|
||||
done[lhs] = spec
|
||||
table.insert(self.keys, spec)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue