From ea38a944837e00e4a9f62614cb46bdccf3cda976 Mon Sep 17 00:00:00 2001 From: JumpyJacko Date: Fri, 12 Jul 2024 12:50:57 +1000 Subject: [PATCH 1/2] fix: change nvim_input to nvim_feedkeys --- lua/better_escape.lua | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lua/better_escape.lua b/lua/better_escape.lua index 8160c9b..5274663 100644 --- a/lua/better_escape.lua +++ b/lua/better_escape.lua @@ -120,14 +120,32 @@ local function map_keys() record_key(second_key) return second_key end - vim.api.nvim_input(undo_key[mode] or "") + vim.api.nvim_feedkeys( + vim.api.nvim_replace_termcodes( + undo_key[mode] or "", + true, + false, + true + ), + "n", + false + ) vim.api.nvim_input( ("setlocal %smodified"):format( bufmodified and "" or "no" ) ) if type(mapping) == "string" then - vim.api.nvim_input(mapping) + vim.api.nvim_feedkeys( + vim.api.nvim_replace_termcodes( + mapping, + true, + false, + true + ), + "n", + false + ) elseif type(mapping) == "function" then vim.api.nvim_input(mapping() or "") end From ec832a05c1f6c7826cc209bede6fbc2d0d50b1c1 Mon Sep 17 00:00:00 2001 From: Jackson Ly <48436180+jumpyjacko@users.noreply.github.com> Date: Fri, 12 Jul 2024 21:41:07 +1000 Subject: [PATCH 2/2] fix: change nvim_input to nvim_feedkeys for function mappings Thanks @Sam-programs! Co-authored-by: Sam <130783534+Sam-programs@users.noreply.github.com> --- lua/better_escape.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lua/better_escape.lua b/lua/better_escape.lua index 5274663..b68c964 100644 --- a/lua/better_escape.lua +++ b/lua/better_escape.lua @@ -147,7 +147,15 @@ local function map_keys() false ) elseif type(mapping) == "function" then - vim.api.nvim_input(mapping() or "") + vim.api.nvim_feedkeys( + vim.api.nvim_replace_termcodes( + mapping() or "", + true, + false, + true + ), + "n", + false) end end, map_opts) ::continue::