Skip to content

Commit

Permalink
fix: recursion on ctrl-keys mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
Wansmer committed Mar 28, 2024
1 parent 8fa0263 commit 4c11636
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lua/langmapper/auto.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ local function automapping(scope, bufnr)
for _, map in ipairs(mappings) do
local lhs = u.translate_keycode(map.lhs, lang)
for _, mode in ipairs(map.mode) do
if not (map.lhs == lhs or has_map(lhs, mode, mappings)) then
-- Prevent recursion on ctrl-keys. E.g. both layouts contains the same keys. See: #23
local is_same = vim.startswith(lhs:lower(), '<c-') and lhs:lower() == map.lhs:lower() or lhs == map.lhs
if not (is_same or has_map(lhs, mode, mappings)) then
local rhs = function()
local repl = vim.api.nvim_replace_termcodes(map.lhs, true, true, true)
vim.api.nvim_feedkeys(repl, 'm', true)
Expand Down

0 comments on commit 4c11636

Please sign in to comment.