From 25a14001e587ce3068b3b2204c330fdd5a09b877 Mon Sep 17 00:00:00 2001 From: Sam-programs <130783534+Sam-programs@users.noreply.github.com> Date: Sat, 27 Jul 2024 11:28:09 +0300 Subject: [PATCH] fix: macro regression --- lua/better_escape.lua | 48 ++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/lua/better_escape.lua b/lua/better_escape.lua index 647455f..2c14720 100644 --- a/lua/better_escape.lua +++ b/lua/better_escape.lua @@ -1,5 +1,8 @@ local M = {} local uv = vim.uv or vim.loop +local t = function(str) + return vim.api.nvim_replace_termcodes(str, true, true, true) +end M.waiting = false @@ -123,43 +126,22 @@ local function map_keys() record_key(second_key) return second_key end - 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" + local keys = "" + keys = keys + .. t( + (undo_key[mode] or "") + .. ( + ("setlocal %smodified"):format( + bufmodified and "" or "no" + ) + ) ) - ) if type(mapping) == "string" then - vim.api.nvim_feedkeys( - vim.api.nvim_replace_termcodes( - mapping, - true, - false, - true - ), - "n", - false - ) + keys = keys .. t(mapping) elseif type(mapping) == "function" then - vim.api.nvim_feedkeys( - vim.api.nvim_replace_termcodes( - mapping() or "", - true, - false, - true - ), - "n", - false) + keys = keys .. t(mapping() or "") end + vim.api.nvim_feedkeys(keys, "in", false) end, map_opts) ::continue:: end