To: vim_dev@googlegroups.com Subject: Patch 8.1.0466 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0466 (after 8.1.0463) Problem: Autocmd test fails. Solution: Do call inchar() when flushing typeahead. Files: src/vim.h, src/getchar.c, src/proto/getchar.pro, src/memline.c, src/message.c, src/misc1.c *** ../vim-8.1.0465/src/vim.h 2018-09-18 22:29:59.888041388 +0200 --- src/vim.h 2018-10-07 23:01:47.537604844 +0200 *************** *** 2108,2113 **** --- 2108,2120 ---- 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 */ *** ../vim-8.1.0465/src/getchar.c 2018-09-30 21:43:17.187693348 +0200 --- src/getchar.c 2018-10-07 23:05:48.079859873 +0200 *************** *** 438,444 **** * flush all typeahead characters (used when interrupted by a CTRL-C). */ void ! flush_buffers(int flush_typeahead) { init_typebuf(); --- 438,444 ---- * flush all typeahead characters (used when interrupted by a CTRL-C). */ void ! flush_buffers(flush_buffers_T flush_typeahead) { init_typebuf(); *************** *** 446,460 **** while (read_readbuffers(TRUE) != NUL) ; ! if (flush_typeahead) /* remove all typeahead */ { ! /* ! * 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) --- 446,466 ---- while (read_readbuffers(TRUE) != NUL) ; ! if (flush_typeahead == FLUSH_MINIMAL) { ! // 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,473 **** 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; --- 469,474 ---- *************** *** 1858,1863 **** --- 1859,1865 ---- * 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,1962 **** * 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. * * When "no_mapping" is zero, checks for mappings in the current mode. * Only returns one byte (of a multi-byte character). --- 1958,1965 ---- * 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. ! * 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,2090 **** c = ESC; else c = Ctrl_C; ! flush_buffers(TRUE); /* flush all typeahead */ if (advance) { --- 2087,2093 ---- c = ESC; else c = Ctrl_C; ! flush_buffers(FLUSH_INPUT); // flush all typeahead if (advance) { *************** *** 2510,2516 **** redrawcmdline(); else setcursor(); ! flush_buffers(FALSE); mapdepth = 0; /* for next one */ c = -1; break; --- 2513,2519 ---- redrawcmdline(); else setcursor(); ! flush_buffers(FLUSH_MINIMAL); mapdepth = 0; /* for next one */ c = -1; break; *** ../vim-8.1.0465/src/proto/getchar.pro 2018-05-17 13:52:36.000000000 +0200 --- src/proto/getchar.pro 2018-10-07 23:07:15.159189769 +0200 *************** *** 5,11 **** int stuff_empty(void); int readbuf1_empty(void); void typeahead_noflush(int c); ! void flush_buffers(int flush_typeahead); void ResetRedobuff(void); void CancelRedo(void); void saveRedobuff(save_redo_T *save_redo); --- 5,11 ---- int stuff_empty(void); int readbuf1_empty(void); void typeahead_noflush(int c); ! void flush_buffers(flush_buffers_T flush_typeahead); void ResetRedobuff(void); void CancelRedo(void); void saveRedobuff(save_redo_T *save_redo); *** ../vim-8.1.0465/src/memline.c 2018-10-07 20:48:33.941433087 +0200 --- src/memline.c 2018-10-07 23:06:02.015753778 +0200 *************** *** 4522,4528 **** // If vimrc has "simalt ~x" we don't want it to // interfere with the prompt here. ! flush_buffers(TRUE); } #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) --- 4522,4528 ---- // If vimrc has "simalt ~x" we don't want it to // interfere with the prompt here. ! flush_buffers(FLUSH_TYPEAHEAD); } #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) *** ../vim-8.1.0465/src/message.c 2018-09-30 21:43:17.195693290 +0200 --- src/message.c 2018-10-07 23:06:29.651542067 +0200 *************** *** 688,695 **** if (p_eb) beep_flush(); /* also includes flush_buffers() */ else ! flush_buffers(FALSE); /* flush internal buffers */ ! did_emsg = TRUE; /* flag for DoOneCmd() */ #ifdef FEAT_EVAL did_uncaught_emsg = TRUE; #endif --- 688,695 ---- if (p_eb) beep_flush(); /* also includes flush_buffers() */ else ! flush_buffers(FLUSH_MINIMAL); // flush internal buffers ! did_emsg = TRUE; // flag for DoOneCmd() #ifdef FEAT_EVAL did_uncaught_emsg = TRUE; #endif *** ../vim-8.1.0465/src/misc1.c 2018-09-30 21:43:17.195693290 +0200 --- src/misc1.c 2018-10-07 23:07:05.159267560 +0200 *************** *** 3825,3831 **** { if (emsg_silent == 0) { ! flush_buffers(FALSE); vim_beep(BO_ERROR); } } --- 3825,3831 ---- { if (emsg_silent == 0) { ! flush_buffers(FLUSH_MINIMAL); vim_beep(BO_ERROR); } } *** ../vim-8.1.0465/src/version.c 2018-10-07 22:47:03.633199859 +0200 --- src/version.c 2018-10-07 23:04:59.372226904 +0200 *************** *** 794,795 **** --- 794,797 ---- { /* Add new patch number below this line */ + /**/ + 466, /**/ -- hundred-and-one symptoms of being an internet addict: 174. You know what a listserv is. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///