diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-08-12 06:50:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-12 06:50:52 +0800 |
commit | 72cf94fc0e69b7a049ae2990572876d641cf5cb9 (patch) | |
tree | 8db245af9fb892df25fd175f19c6ab03006ee3fe /src/nvim/normal.c | |
parent | 8c5d81997e56a72fbb1392846a146cab2eb74b7f (diff) | |
download | rneovim-72cf94fc0e69b7a049ae2990572876d641cf5cb9.tar.gz rneovim-72cf94fc0e69b7a049ae2990572876d641cf5cb9.tar.bz2 rneovim-72cf94fc0e69b7a049ae2990572876d641cf5cb9.zip |
vim-patch:9.0.1694: wrong mapping applied when replaying a char search (#24670)
Problem: wrong mapping applied when replaying a char search
Solution: Store a NOP after the ESC
closes: vim/vim#12708
closes: vim/vim#6350
https://github.com/vim/vim/commit/bacc83009bc38c9ba0247aaa22b76d1993d57993
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r-- | src/nvim/normal.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index b82a6b928d..1e9bc78fe3 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -807,25 +807,32 @@ static void normal_get_additional_char(NormalState *s) } } - // 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 (lang && (s->c = vpeekc()) > 0 - && (s->c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) { - s->c = plain_vgetc(); - if (!utf_iscomposing(s->c)) { - vungetc(s->c); // it wasn't, put it back - break; - } else if (s->ca.ncharC1 == 0) { - s->ca.ncharC1 = s->c; - } else { - s->ca.ncharC2 = s->c; + if (lang) { + // 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 (lang && (s->c = vpeekc()) > 0 + && (s->c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) { + s->c = plain_vgetc(); + if (!utf_iscomposing(s->c)) { + vungetc(s->c); // it wasn't, put it back + break; + } else if (s->ca.ncharC1 == 0) { + s->ca.ncharC1 = s->c; + } else { + s->ca.ncharC2 = s->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--; |