]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.1.0466: autocmd test fails v8.1.0466
authorBram Moolenaar <Bram@vim.org>
Sun, 7 Oct 2018 21:16:36 +0000 (23:16 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 7 Oct 2018 21:16:36 +0000 (23:16 +0200)
Problem:    Autocmd test fails.
Solution:   Do call inchar() when flushing typeahead.

src/getchar.c
src/memline.c
src/message.c
src/misc1.c
src/proto/getchar.pro
src/version.c
src/vim.h

index 679eae160322e8767c3e18bd6c0288890f233df1..53c0ef35bf6c7dcfbc46d4cdd7497ed5edddc41c 100644 (file)
@@ -438,7 +438,7 @@ typeahead_noflush(int c)
  * flush all typeahead characters (used when interrupted by a CTRL-C).
  */
     void
-flush_buffers(int flush_typeahead)
+flush_buffers(flush_buffers_T flush_typeahead)
 {
     init_typebuf();
 
@@ -446,15 +446,21 @@ flush_buffers(int flush_typeahead)
     while (read_readbuffers(TRUE) != NUL)
        ;
 
-    if (flush_typeahead)           /* remove all typeahead */
+    if (flush_typeahead == FLUSH_MINIMAL)
     {
-       /*
-        * We have to get all characters, because we may delete the first part
-        * of an escape sequence.
-        * In an xterm we get one char at a time and we have to get them all.
-        */
-       while (inchar(typebuf.tb_buf, typebuf.tb_buflen - 1, 10L) != 0)
-           ;
+       // remove mapped characters at the start only
+       typebuf.tb_off += typebuf.tb_maplen;
+       typebuf.tb_len -= typebuf.tb_maplen;
+    }
+    else
+    {
+       // remove typeahead
+       if (flush_typeahead == FLUSH_INPUT)
+           // We have to get all characters, because we may delete the first
+           // part of an escape sequence.  In an xterm we get one char at a
+           // time and we have to get them all.
+           while (inchar(typebuf.tb_buf, typebuf.tb_buflen - 1, 10L) != 0)
+               ;
        typebuf.tb_off = MAXMAPLEN;
        typebuf.tb_len = 0;
 #if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL)
@@ -463,11 +469,6 @@ flush_buffers(int flush_typeahead)
        typebuf_was_filled = FALSE;
 #endif
     }
-    else                   /* remove mapped characters at the start only */
-    {
-       typebuf.tb_off += typebuf.tb_maplen;
-       typebuf.tb_len -= typebuf.tb_maplen;
-    }
     typebuf.tb_maplen = 0;
     typebuf.tb_silent = 0;
     cmd_silent = FALSE;
@@ -1858,6 +1859,7 @@ plain_vgetc(void)
  * Check if a character is available, such that vgetc() will not block.
  * If the next character is a special character or multi-byte, the returned
  * character is not valid!.
+ * Returns NUL if no character is available.
  */
     int
 vpeekc(void)
@@ -1956,7 +1958,8 @@ vungetc(int c)
  *     KeyTyped is set to TRUE in the case the user typed the key.
  *     KeyStuffed is TRUE if the character comes from the stuff buffer.
  * if "advance" is FALSE (vpeekc()):
- *     just look whether there is a character available.
+ *     Just look whether there is a character available.
+ *     Return NUL if not.
  *
  * When "no_mapping" is zero, checks for mappings in the current mode.
  * Only returns one byte (of a multi-byte character).
@@ -2084,7 +2087,7 @@ vgetorpeek(int advance)
                        c = ESC;
                    else
                        c = Ctrl_C;
-                   flush_buffers(TRUE);        /* flush all typeahead */
+                   flush_buffers(FLUSH_INPUT); // flush all typeahead
 
                    if (advance)
                    {
@@ -2510,7 +2513,7 @@ vgetorpeek(int advance)
                                redrawcmdline();
                            else
                                setcursor();
-                           flush_buffers(FALSE);
+                           flush_buffers(FLUSH_MINIMAL);
                            mapdepth = 0;       /* for next one */
                            c = -1;
                            break;
index f7a3d06a71a95cef789789e8b2cfb9a1202d33e7..0881e6c7ad75181dd63e9f7bd030a817a32199cf 100644 (file)
@@ -4522,7 +4522,7 @@ findswapname(
 
                        // If vimrc has "simalt ~x" we don't want it to
                        // interfere with the prompt here.
-                       flush_buffers(TRUE);
+                       flush_buffers(FLUSH_TYPEAHEAD);
                    }
 
 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
index c7ecb6196306acd57619c8448b839d560c9847cf..c2318bd8af469637bcc9e4a6e1f6ed359ed1cd96 100644 (file)
@@ -688,8 +688,8 @@ emsg(char_u *s)
        if (p_eb)
            beep_flush();               /* also includes flush_buffers() */
        else
-           flush_buffers(FALSE);       /* flush internal buffers */
-       did_emsg = TRUE;                /* flag for DoOneCmd() */
+           flush_buffers(FLUSH_MINIMAL);  // flush internal buffers
+       did_emsg = TRUE;                   // flag for DoOneCmd()
 #ifdef FEAT_EVAL
        did_uncaught_emsg = TRUE;
 #endif
index 34b4134a04c0b07ed7d2c2e083f9d1ae7f440129..820f8f994fb789ead6cfd959f3867f162ce5ebef 100644 (file)
@@ -3825,7 +3825,7 @@ beep_flush(void)
 {
     if (emsg_silent == 0)
     {
-       flush_buffers(FALSE);
+       flush_buffers(FLUSH_MINIMAL);
        vim_beep(BO_ERROR);
     }
 }
index aac522f1529e440fc44bdd736257ea12d20f0d90..07336627fc6eb8aea300f228f46e6885cc7f1881 100644 (file)
@@ -5,7 +5,7 @@ char_u *get_inserted(void);
 int stuff_empty(void);
 int readbuf1_empty(void);
 void typeahead_noflush(int c);
-void flush_buffers(int flush_typeahead);
+void flush_buffers(flush_buffers_T flush_typeahead);
 void ResetRedobuff(void);
 void CancelRedo(void);
 void saveRedobuff(save_redo_T *save_redo);
index 9f4991aa663146da72e489092c6dde5ac9b15780..c416032f56bc988f7828dbd7b919b74dd61f0ff4 100644 (file)
@@ -792,6 +792,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    466,
 /**/
     465,
 /**/
index cb72711cc219b05e5422801b0cdf1ecb1275f604..7a66ab0e29998e80f91278fc2d5f63275795a335 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -2108,6 +2108,13 @@ typedef enum {
     PASTE_ONE_CHAR     /* return first character */
 } paste_mode_T;
 
+// Argument for flush_buffers().
+typedef enum {
+    FLUSH_MINIMAL,
+    FLUSH_TYPEAHEAD,   // flush current typebuf contents
+    FLUSH_INPUT                // flush typebuf and inchar() input
+} flush_buffers_T;
+
 #include "ex_cmds.h"       /* Ex command defines */
 #include "spell.h"         /* spell checking stuff */