@@ -438,23 +438,29 @@ typeahead_noflush(int c)
438438 * flush all typeahead characters (used when interrupted by a CTRL-C).
439439 */
440440 void
441- flush_buffers (int flush_typeahead )
441+ flush_buffers (flush_buffers_T flush_typeahead )
442442{
443443 init_typebuf ();
444444
445445 start_stuff ();
446446 while (read_readbuffers (TRUE) != NUL )
447447 ;
448448
449- if (flush_typeahead ) /* remove all typeahead */
449+ if (flush_typeahead == FLUSH_MINIMAL )
450450 {
451- /*
452- * We have to get all characters, because we may delete the first part
453- * of an escape sequence.
454- * In an xterm we get one char at a time and we have to get them all.
455- */
456- while (inchar (typebuf .tb_buf , typebuf .tb_buflen - 1 , 10L ) != 0 )
457- ;
451+ // remove mapped characters at the start only
452+ typebuf .tb_off += typebuf .tb_maplen ;
453+ typebuf .tb_len -= typebuf .tb_maplen ;
454+ }
455+ else
456+ {
457+ // remove typeahead
458+ if (flush_typeahead == FLUSH_INPUT )
459+ // We have to get all characters, because we may delete the first
460+ // part of an escape sequence. In an xterm we get one char at a
461+ // time and we have to get them all.
462+ while (inchar (typebuf .tb_buf , typebuf .tb_buflen - 1 , 10L ) != 0 )
463+ ;
458464 typebuf .tb_off = MAXMAPLEN ;
459465 typebuf .tb_len = 0 ;
460466#if defined(FEAT_CLIENTSERVER ) || defined(FEAT_EVAL )
@@ -463,11 +469,6 @@ flush_buffers(int flush_typeahead)
463469 typebuf_was_filled = FALSE;
464470#endif
465471 }
466- else /* remove mapped characters at the start only */
467- {
468- typebuf .tb_off += typebuf .tb_maplen ;
469- typebuf .tb_len -= typebuf .tb_maplen ;
470- }
471472 typebuf .tb_maplen = 0 ;
472473 typebuf .tb_silent = 0 ;
473474 cmd_silent = FALSE;
@@ -1858,6 +1859,7 @@ plain_vgetc(void)
18581859 * Check if a character is available, such that vgetc() will not block.
18591860 * If the next character is a special character or multi-byte, the returned
18601861 * character is not valid!.
1862+ * Returns NUL if no character is available.
18611863 */
18621864 int
18631865vpeekc (void )
@@ -1956,7 +1958,8 @@ vungetc(int c)
19561958 * KeyTyped is set to TRUE in the case the user typed the key.
19571959 * KeyStuffed is TRUE if the character comes from the stuff buffer.
19581960 * if "advance" is FALSE (vpeekc()):
1959- * just look whether there is a character available.
1961+ * Just look whether there is a character available.
1962+ * Return NUL if not.
19601963 *
19611964 * When "no_mapping" is zero, checks for mappings in the current mode.
19621965 * Only returns one byte (of a multi-byte character).
@@ -2084,7 +2087,7 @@ vgetorpeek(int advance)
20842087 c = ESC ;
20852088 else
20862089 c = Ctrl_C ;
2087- flush_buffers (TRUE ); /* flush all typeahead */
2090+ flush_buffers (FLUSH_INPUT ); // flush all typeahead
20882091
20892092 if (advance )
20902093 {
@@ -2510,7 +2513,7 @@ vgetorpeek(int advance)
25102513 redrawcmdline ();
25112514 else
25122515 setcursor ();
2513- flush_buffers (FALSE );
2516+ flush_buffers (FLUSH_MINIMAL );
25142517 mapdepth = 0 ; /* for next one */
25152518 c = -1 ;
25162519 break ;
0 commit comments