]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.091 v7.3.091
authorBram Moolenaar <Bram@vim.org>
Thu, 30 Dec 2010 11:30:31 +0000 (12:30 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 30 Dec 2010 11:30:31 +0000 (12:30 +0100)
Problem:    "vim -w foo" writes special key codes for removed escape
            sequences. (Josh Triplett)
Solution:   Don't write K_IGNORE codes.

src/getchar.c
src/misc1.c
src/term.c
src/version.c
src/vim.h

index ecb03790073cc0214a41496dde01fbcecbc1dab4..63b93a547b44f036fede1a47549cfb397b49521f 100644 (file)
@@ -1506,9 +1506,6 @@ updatescript(c)
     }
 }
 
-#define KL_PART_KEY -1         /* keylen value for incomplete key-code */
-#define KL_PART_MAP -2         /* keylen value for incomplete mapping */
-
 /*
  * Get the next input character.
  * Can return a special key or a multi-byte character.
@@ -2171,7 +2168,7 @@ vgetorpeek(advance)
                                        if (!timedout)
                                        {
                                            /* break at a partly match */
-                                           keylen = KL_PART_MAP;
+                                           keylen = KEYLEN_PART_MAP;
                                            break;
                                        }
                                    }
@@ -2192,7 +2189,7 @@ vgetorpeek(advance)
 
                        /* If no partly match found, use the longest full
                         * match. */
-                       if (keylen != KL_PART_MAP)
+                       if (keylen != KEYLEN_PART_MAP)
                        {
                            mp = mp_match;
                            keylen = mp_match_len;
@@ -2230,7 +2227,7 @@ vgetorpeek(advance)
                        }
                        /* Need more chars for partly match. */
                        if (mlen == typebuf.tb_len)
-                           keylen = KL_PART_KEY;
+                           keylen = KEYLEN_PART_KEY;
                        else if (max_mlen < mlen)
                            /* no match, may have to check for termcode at
                             * next character */
@@ -2238,7 +2235,7 @@ vgetorpeek(advance)
                    }
 
                    if ((mp == NULL || max_mlen >= mp_match_len)
-                                                    && keylen != KL_PART_MAP)
+                                                && keylen != KEYLEN_PART_MAP)
                    {
                        int     save_keylen = keylen;
 
@@ -2264,8 +2261,8 @@ vgetorpeek(advance)
                            /* If no termcode matched but 'pastetoggle'
                             * matched partially it's like an incomplete key
                             * sequence. */
-                           if (keylen == 0 && save_keylen == KL_PART_KEY)
-                               keylen = KL_PART_KEY;
+                           if (keylen == 0 && save_keylen == KEYLEN_PART_KEY)
+                               keylen = KEYLEN_PART_KEY;
 
                            /*
                             * When getting a partial match, but the last
@@ -2302,7 +2299,7 @@ vgetorpeek(advance)
                                    continue;
                                }
                                if (*s == NUL)      /* need more characters */
-                                   keylen = KL_PART_KEY;
+                                   keylen = KEYLEN_PART_KEY;
                            }
                            if (keylen >= 0)
 #endif
@@ -2339,7 +2336,8 @@ vgetorpeek(advance)
                        if (keylen > 0)     /* full matching terminal code */
                        {
 #if defined(FEAT_GUI) && defined(FEAT_MENU)
-                           if (typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL
+                           if (typebuf.tb_len >= 2
+                               && typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL
                                         && typebuf.tb_buf[typebuf.tb_off + 1]
                                                                   == KS_MENU)
                            {
@@ -2381,7 +2379,7 @@ vgetorpeek(advance)
                        /* Partial match: get some more characters.  When a
                         * matching mapping was found use that one. */
                        if (mp == NULL || keylen < 0)
-                           keylen = KL_PART_KEY;
+                           keylen = KEYLEN_PART_KEY;
                        else
                            keylen = mp_match_len;
                    }
@@ -2553,7 +2551,8 @@ vgetorpeek(advance)
 #endif
                        && typebuf.tb_maplen == 0
                        && (State & INSERT)
-                       && (p_timeout || (keylen == KL_PART_KEY && p_ttimeout))
+                       && (p_timeout
+                           || (keylen == KEYLEN_PART_KEY && p_ttimeout))
                        && (c = inchar(typebuf.tb_buf + typebuf.tb_off
                                                     + typebuf.tb_len, 3, 25L,
                                                 typebuf.tb_change_cnt)) == 0)
@@ -2783,9 +2782,9 @@ vgetorpeek(advance)
                            ? 0
                            : ((typebuf.tb_len == 0
                                    || !(p_timeout || (p_ttimeout
-                                                  && keylen == KL_PART_KEY)))
+                                              && keylen == KEYLEN_PART_KEY)))
                                    ? -1L
-                                   : ((keylen == KL_PART_KEY && p_ttm >= 0)
+                                   : ((keylen == KEYLEN_PART_KEY && p_ttm >= 0)
                                            ? p_ttm
                                            : p_tm)), typebuf.tb_change_cnt);
 
index b14f2ed1453184257b7c1c8608545546021a267b..7235617fce6b64022b1479eafa21e81f0f6f9452 100644 (file)
@@ -3114,10 +3114,11 @@ get_keystroke()
               && (!p_ttimeout || waited * 100L < (p_ttm < 0 ? p_tm : p_ttm)))
            continue;
 
-       /* found a termcode: adjust length */
-       if (n > 0)
+       if (n == KEYLEN_REMOVED)  /* key code removed */
+           continue;
+       if (n > 0)              /* found a termcode: adjust length */
            len = n;
-       if (len == 0)       /* nothing typed yet */
+       if (len == 0)           /* nothing typed yet */
            continue;
 
        /* Handle modifier and/or special key code. */
index 8c426620c947b31ac6509e7977b818a54a4572ac..15a386493e05f76d353c455b76f1dd6214196495 100644 (file)
@@ -3828,6 +3828,7 @@ set_mouse_topline(wp)
  * Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off
  * + max_offset].
  * Return 0 for no match, -1 for partial match, > 0 for full match.
+ * Return KEYLEN_REMOVED when a key code was deleted.
  * With a match, the match is removed, the replacement code is inserted in
  * typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is
  * returned.
@@ -3845,6 +3846,7 @@ check_termcode(max_offset, buf, buflen)
     int                slen = 0;       /* init for GCC */
     int                modslen;
     int                len;
+    int                retval = 0;
     int                offset;
     char_u     key_name[2];
     int                modifiers;
@@ -4940,6 +4942,13 @@ check_termcode(max_offset, buf, buflen)
 #endif
                string[new_slen++] = key_name[1];
        }
+       else if (new_slen == 0 && key_name[0] == KS_EXTRA
+                                                 && key_name[1] == KE_IGNORE)
+       {
+           /* Do not put K_IGNORE into the buffer, do return KEYLEN_REMOVED
+            * to indicate what happened. */
+           retval = KEYLEN_REMOVED;
+       }
        else
        {
            string[new_slen++] = K_SPECIAL;
@@ -4976,7 +4985,7 @@ check_termcode(max_offset, buf, buflen)
                                                   (size_t)(buflen - offset));
            mch_memmove(buf + offset, string, (size_t)new_slen);
        }
-       return (len + extra + offset);
+       return retval == 0 ? (len + extra + offset) : retval;
     }
 
     return 0;                      /* no match found */
index 2e9363e81442f29974f2074dbd6d5f9449f8de51..f1af5d3340d794d8715143dfce0081f3bc94414c 100644 (file)
@@ -714,6 +714,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    91,
 /**/
     90,
 /**/
index 15595bf0381c500991ec38ec4650979c2d3bb017..24c1b16e7c55a790a837654a558575ad11927acd 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -2211,4 +2211,8 @@ typedef int VimClipboard; /* This is required for the prototypes. */
 #define MSCR_LEFT      -1
 #define MSCR_RIGHT     -2
 
+#define KEYLEN_PART_KEY -1     /* keylen value for incomplete key-code */
+#define KEYLEN_PART_MAP -2     /* keylen value for incomplete mapping */
+#define KEYLEN_REMOVED  9999   /* keylen value for removed sequence */
+
 #endif /* VIM__H */