diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-04-27 09:08:24 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-04-29 15:51:04 +0800 |
commit | 9660ddd512653090fc02ec3e84afa97c846f0d61 (patch) | |
tree | 14d0561664fc96685c99e6fe407d71126e172f58 /src | |
parent | 32da3e56cd12210cd567609f2ec7dd4f0c1ee4c6 (diff) | |
download | rneovim-9660ddd512653090fc02ec3e84afa97c846f0d61.tar.gz rneovim-9660ddd512653090fc02ec3e84afa97c846f0d61.tar.bz2 rneovim-9660ddd512653090fc02ec3e84afa97c846f0d61.zip |
vim-patch:8.2.0919: merging modifier for modifyOtherKeys is done twice
Problem: Merging modifier for modifyOtherKeys is done twice.
Solution: Remove the merging done in vgetc().
https://github.com/vim/vim/commit/673fc3e23f09095d17f0095c4323958041b2d0d2
Omit ex_getln.c change as it was removed in patch 8.2.2084, so
no_reduce_keys is still not needed in Nvim.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/getchar.c | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index b7894da206..31cc1ed861 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1630,13 +1630,10 @@ int vgetc(void) c = utf_ptr2char(buf); } - // A modifier was not used for a mapping, apply it to ASCII - // keys. Shift would already have been applied. - // Remember the character and mod_mask from before, in some - // cases they are put back in the typeahead buffer. - vgetc_mod_mask = mod_mask; - vgetc_char = c; - c = merge_modifiers(c, &mod_mask); + if (vgetc_char == 0) { + vgetc_mod_mask = mod_mask; + vgetc_char = c; + } // If mappings are enabled (i.e., not Ctrl-v) and the user directly typed // something with a meta- or alt- modifier that was not mapped, interpret @@ -1784,15 +1781,31 @@ static int check_simplify_modifier(int max_offset) } char_u *tp = typebuf.tb_buf + typebuf.tb_off + offset; if (tp[0] == K_SPECIAL && tp[1] == KS_MODIFIER) { + // A modifier was not used for a mapping, apply it to ASCII + // keys. Shift would already have been applied. int modifier = tp[2]; - int new_c = merge_modifiers(tp[3], &modifier); - - if (new_c != tp[3] && modifier == 0) { + int c = tp[3]; + int new_c = merge_modifiers(c, &modifier); + + if (new_c != c) { + if (offset == 0) { + // At the start: remember the character and mod_mask before + // merging, in some cases, e.g. at the hit-return prompt, + // they are put back in the typeahead buffer. + vgetc_char = c; + vgetc_mod_mask = tp[2]; + } char_u new_string[MB_MAXBYTES]; int len = utf_char2bytes(new_c, new_string); - - if (put_string_in_typebuf(offset, 4, new_string, len) == FAIL) { - return -1; + if (modifier == 0) { + if (put_string_in_typebuf(offset, 4, new_string, len) == FAIL) { + return -1; + } + } else { + tp[2] = (char_u)modifier; + if (put_string_in_typebuf(offset + 3, 1, new_string, len) == FAIL) { + return -1; + } } return len; } |