]> granicus.if.org Git - vim/commitdiff
patch 8.2.0919: merging modifier for modifyOtherKeys is done twice v8.2.0919
authorBram Moolenaar <Bram@vim.org>
Sun, 7 Jun 2020 13:46:11 +0000 (15:46 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 7 Jun 2020 13:46:11 +0000 (15:46 +0200)
Problem:    Merging modifier for modifyOtherKeys is done twice.
Solution:   Remove the merging done in vgetc().

src/ex_getln.c
src/getchar.c
src/version.c

index c003748e9427c2ff203625aca097e936ddea3b19..702b63db5bac3212291c25bd65d954d4450267e2 100644 (file)
@@ -2225,7 +2225,9 @@ getcmdline_int(
 
                    ignore_drag_release = TRUE;
                    putcmdline('^', TRUE);
+                   no_reduce_keys = TRUE;  //  don't merge modifyOtherKeys
                    c = get_literal();      // get next (two) character(s)
+                   no_reduce_keys = FALSE;
                    do_abbr = FALSE;        // don't do abbreviation now
                    extra_char = NUL;
                    // may need to remove ^ when composing char was typed
index de814ccc68622fcc4474587f4590c78b00e38250..fcee7dda721cb750b5e1f683634961c647e97ea7 100644 (file)
@@ -1858,15 +1858,10 @@ vgetc(void)
                c = (*mb_ptr2char)(buf);
            }
 
-           if (!no_reduce_keys)
+           if (vgetc_char == 0)
            {
-               // 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_modifyOtherKeys(c, &mod_mask);
            }
 
            break;
@@ -2274,17 +2269,39 @@ check_simplify_modifier(int max_offset)
        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_modifyOtherKeys(tp[3], &modifier);
+           int c = tp[3];
+           int new_c = merge_modifyOtherKeys(c, &modifier);
 
-           if (new_c != tp[3] && modifier == 0)
+           if (new_c != c)
            {
                char_u  new_string[MB_MAXBYTES];
-               int     len = mb_char2bytes(new_c, new_string);
+               int     len;
 
-               if (put_string_in_typebuf(offset, 4, new_string, len,
+               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];
+               }
+               len = mb_char2bytes(new_c, new_string);
+               if (modifier == 0)
+               {
+                   if (put_string_in_typebuf(offset, 4, new_string, len,
                                                           NULL, 0, 0) == FAIL)
                    return -1;
+               }
+               else
+               {
+                   tp[2] = modifier;
+                   if (put_string_in_typebuf(offset + 3, 1, new_string, len,
+                                                          NULL, 0, 0) == FAIL)
+                   return -1;
+               }
                return len;
            }
        }
@@ -2559,7 +2576,7 @@ handle_mapping(
 
            // If no termcode matched, try to include the modifier into the
            // key.  This for when modifyOtherKeys is working.
-           if (keylen == 0)
+           if (keylen == 0 && !no_reduce_keys)
                keylen = check_simplify_modifier(max_mlen + 1);
 
            // When getting a partial match, but the last characters were not
index 8bd7b8d81cb58b155d3081af49ea49d8528f8802..36207450c2a14c01d38cebff68f4b58e8d949501 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    919,
 /**/
     918,
 /**/