diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2022-04-28 21:18:58 +0800 | 
|---|---|---|
| committer | zeertzjq <zeertzjq@outlook.com> | 2022-04-29 15:51:04 +0800 | 
| commit | 4adf2123dd94a3d5303fe200c7e909067e1cda34 (patch) | |
| tree | f6dcfba23c192f0e127fc53448556b4108d53614 /src/nvim/getchar.c | |
| parent | 1d97781dc53416072387b1d71aeaf11caecd8cf0 (diff) | |
| download | rneovim-4adf2123dd94a3d5303fe200c7e909067e1cda34.tar.gz rneovim-4adf2123dd94a3d5303fe200c7e909067e1cda34.tar.bz2 rneovim-4adf2123dd94a3d5303fe200c7e909067e1cda34.zip  | |
vim-patch:8.2.4837: modifiers not simplified when timed out
Problem:    Modifiers not simplified when timed out or using feedkeys() with
            'n" flag.
Solution:   Adjust how mapped flag and timeout are used. (closes vim/vim#10305)
https://github.com/vim/vim/commit/68a573ce2b996602a86b14d9b258ebb8c657604f
Diffstat (limited to 'src/nvim/getchar.c')
| -rw-r--r-- | src/nvim/getchar.c | 23 | 
1 files changed, 11 insertions, 12 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 5aba241d45..a26ca3f2c8 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -2025,22 +2025,21 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth)    if ((mp == NULL || max_mlen > mp_match_len) && keylen != KEYLEN_PART_MAP) {      // When no matching mapping found or found a non-matching mapping that      // matches at least what the matching mapping matched: -    // Try to include the modifier into the key, when: -    // - mapping is allowed, -    // - keys have not been mapped, -    // - and when not timed out, -    if ((no_mapping == 0 || allow_keys != 0) -        && (typebuf.tb_maplen == 0 -            || (p_remap && typebuf.tb_noremap[typebuf.tb_off] == RM_YES)) -        && !*timedout) { +    // Try to include the modifier into the key when mapping is allowed. +    if (no_mapping == 0 || allow_keys != 0) {        if (tb_c1 == K_SPECIAL            && (typebuf.tb_len < 2 -              || (typebuf.tb_buf[typebuf.tb_off + 1] == KS_MODIFIER -                  && typebuf.tb_len < 4))) { +              || (typebuf.tb_buf[typebuf.tb_off + 1] == KS_MODIFIER && typebuf.tb_len < 4))) {          // Incomplete modifier sequence: cannot decide whether to simplify yet.          keylen = KEYLEN_PART_KEY; -        // Don't simplify if 'pastetoggle' matched partially. -      } else if (keylen != KEYLEN_PART_KEY) { +      } else if (keylen == KEYLEN_PART_KEY && !*timedout) { +        // If 'pastetoggle' matched partially, don't simplify. +        // When the last characters were not typed, don't wait for a typed character to +        // complete 'pastetoggle'. +        if (typebuf.tb_len == typebuf.tb_maplen) { +          keylen = 0; +        } +      } else {          // Try to include the modifier into the key.          keylen = check_simplify_modifier(max_mlen + 1);          if (keylen < 0) {  | 
