diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 1c8eb7a5a5..f37d3367d0 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1006,6 +1006,7 @@ int ins_char_typebuf(int c, int modifier) buf[len + 1] = (char_u)K_SECOND(c); buf[len + 2] = (char_u)K_THIRD(c); buf[len + 3] = NUL; + len += 3; } else { char_u *end = add_char2buf(c, buf + len); *end = NUL; diff --git a/test/functional/editor/meta_key_spec.lua b/test/functional/editor/meta_key_spec.lua index 8efcc81616..23964ca10f 100644 --- a/test/functional/editor/meta_key_spec.lua +++ b/test/functional/editor/meta_key_spec.lua @@ -106,6 +106,7 @@ describe('meta-keys #8226 #13042', function() end) it('ALT/META when recording a macro #13235', function() + command('inoremap M-ESC>') feed('ifoobarbazgg0') -- is reinterpreted as " feed('qrviw"ayC// This is some text: apq') @@ -113,7 +114,27 @@ describe('meta-keys #8226 #13042', function() // This is some text: foo bar baz]]) - -- Should not insert an extra double quote when replaying + -- Should not insert an extra double quote or trigger when replaying + feed('j0@rj0@@') + expect([[ + // This is some text: foo + // This is some text: bar + // This is some text: baz]]) + command('%delete') + end) + + it('ALT/META with special key when recording a macro', function() + command('inoremap M-ESC>') + command('noremap "') + command('noremap! "') + feed('ifoobarbazgg0') + -- is reinterpreted as + feed('qrviwayC// This is some text: apq') + expect([[ + // This is some text: foo + bar + baz]]) + -- Should not insert an extra double quote or trigger when replaying feed('j0@rj0@@') expect([[ // This is some text: foo