diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-08-12 00:09:31 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2023-08-12 00:09:31 +0200 |
commit | bacc83009bc38c9ba0247aaa22b76d1993d57993 (patch) | |
tree | cb8534344967454cd4be03c7c78943103ff02be3 /src/normal.c | |
parent | 2d63e4b3ccc0bb34db21a3c1d024cb114f8c4071 (diff) |
patch 9.0.1694: wrong mapping applied when replaying a char searchv9.0.1694
Problem: wrong mapping applied when replaying a char search
Solution: Store a NOP after the ESC
closes: #12708
closes: #6350
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Diffstat (limited to 'src/normal.c')
-rw-r--r-- | src/normal.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/src/normal.c b/src/normal.c index 1aad0b1b3a..2eb2c3841a 100644 --- a/src/normal.c +++ b/src/normal.c @@ -543,27 +543,35 @@ normal_cmd_get_more_chars( } } - // When getting a text character and the next character is a - // multi-byte character, it could be a composing character. - // However, don't wait for it to arrive. Also, do enable mapping, - // because if it's put back with vungetc() it's too late to apply - // mapping. - --no_mapping; - while (enc_utf8 && lang && (c = vpeekc()) > 0 - && (c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) + if (enc_utf8 && lang) { - c = plain_vgetc(); - if (!utf_iscomposing(c)) + // When getting a text character and the next character is a + // multi-byte character, it could be a composing character. + // However, don't wait for it to arrive. Also, do enable mapping, + // because if it's put back with vungetc() it's too late to apply + // mapping. + --no_mapping; + while ((c = vpeekc()) > 0 + && (c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) { - vungetc(c); // it wasn't, put it back - break; + c = plain_vgetc(); + if (!utf_iscomposing(c)) + { + vungetc(c); // it wasn't, put it back + break; + } + else if (cap->ncharC1 == 0) + cap->ncharC1 = c; + else + cap->ncharC2 = c; } - else if (cap->ncharC1 == 0) - cap->ncharC1 = c; - else - cap->ncharC2 = c; + ++no_mapping; + // Vim may be in a different mode when the user types the next key, + // but when replaying a recording the next key is already in the + // typeahead buffer, so record a <Nop> before that to prevent the + // vpeekc() above from applying wrong mappings when replaying. + gotchars_nop(); } - ++no_mapping; } --no_mapping; --allow_keys; |