Skip to content

Commit

Permalink
Merge pull request #84 from jumpyjacko/fix/unwanted-keymap-behaviour
Browse files Browse the repository at this point in the history
fix: possibly unwanted keymap behaviour
  • Loading branch information
max397574 authored Jul 20, 2024
2 parents 8b2b7fb + ec832a0 commit fd53886
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions lua/better_escape.lua
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,42 @@ local function map_keys()
vim.api.nvim_feedkeys(t(second_key), "in", false)
return
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(
("<cmd>setlocal %smodified<cr>"):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 "")
vim.api.nvim_feedkeys(
vim.api.nvim_replace_termcodes(
mapping() or "",
true,
false,
true
),
"n",
false)
end
end)
::continue::
Expand Down

0 comments on commit fd53886

Please sign in to comment.