From 1438f924503805f4bf68d67db72151c28eafc175 Mon Sep 17 00:00:00 2001 From: "Wansmer (Ivan Smirnov)" Date: Thu, 28 Mar 2024 10:07:18 +0300 Subject: [PATCH] fix: recursion on ctrl-keys mappings --- lua/langmapper/auto.lua | 4 +++- lua/langmapper/utils.lua | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/langmapper/auto.lua b/lua/langmapper/auto.lua index 498c400..437b680 100644 --- a/lua/langmapper/auto.lua +++ b/lua/langmapper/auto.lua @@ -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 mappings + local is_same = vim.startswith(map.lhs:lower(), '' local desc = M.update_desc(nil, 'feedkeys', keycode) -- Prevent recursion - if not from:find(tr_char, 1, true) then + if not from:find(tr_char, 1, true) and not char == tr_char then local term_keycodes = vim.api.nvim_replace_termcodes(keycode, true, true, true) keymap(modes, tr_keycode, function() vim.api.nvim_feedkeys(term_keycodes, 'm', true)