fix(keys): don't escape pendig keys twice and only convert when number

This commit is contained in:
Folke Lemaitre 2022-12-26 15:55:40 +01:00
parent 9a2ecc8750
commit 46280a191b
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 4 additions and 2 deletions

View File

@ -16,13 +16,15 @@ local M = {}
function M.retrigger(keys)
local pending = ""
while true do
---@type number|string
local c = vim.fn.getchar(0)
if c == 0 then
break
end
pending = pending .. vim.fn.nr2char(c)
c = type(c) == "number" and vim.fn.nr2char(c) or c
pending = pending .. c
end
local feed = vim.api.nvim_replace_termcodes(keys .. pending, true, true, true)
local feed = vim.api.nvim_replace_termcodes(keys, true, false, true) .. pending
vim.api.nvim_feedkeys(feed, "m", false)
end