From 75f4741db92768db1db937fd4dbce15a01b65042 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 29 Jan 2022 06:05:14 +0800 Subject: [PATCH] fix(input): remove reinterpreted ALT/META chords from recorded macro --- src/nvim/getchar.c | 5 +++-- test/functional/editor/meta_key_spec.lua | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 55bcfa0e97..3e0f01852e 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1598,8 +1598,9 @@ int vgetc(void) if (!no_mapping && KeyTyped && !(State & TERM_FOCUS) && (mod_mask == MOD_MASK_ALT || mod_mask == MOD_MASK_META)) { mod_mask = 0; - ins_char_typebuf(c, 0); - ins_char_typebuf(ESC, 0); + int len = ins_char_typebuf(c, 0); + (void)ins_char_typebuf(ESC, 0); + ungetchars(len + 3); // The ALT/META modifier takes three more bytes continue; } diff --git a/test/functional/editor/meta_key_spec.lua b/test/functional/editor/meta_key_spec.lua index f811b8ae8d..8efcc81616 100644 --- a/test/functional/editor/meta_key_spec.lua +++ b/test/functional/editor/meta_key_spec.lua @@ -104,4 +104,20 @@ describe('meta-keys #8226 #13042', function() eq({ 0, 2, 1, 0, }, funcs.getpos('.')) eq('nt', eval('mode(1)')) end) + + it('ALT/META when recording a macro #13235', function() + feed('ifoobarbazgg0') + -- is reinterpreted as " + feed('qrviw"ayC// This is some text: apq') + expect([[ + // This is some text: foo + bar + baz]]) + -- Should not insert an extra double quote when replaying + feed('j0@rj0@@') + expect([[ + // This is some text: foo + // This is some text: bar + // This is some text: baz]]) + end) end)