Skip to content

Commit 9a2260d

Browse files
h-eastclaudechrisbra
committed
patch 9.2.0238: showmode message may not be displayed
Problem: showmode message may not be displayed (Yee Cheng Chin) Solution: Don't call char_avail() in skip_showmode(), but check for anything in the stuff and typeahead buffer (Hirohito Higashi). Fix "-- VISUAL --" not shown when terminal responses are pending When starting Vim with a script that enters Visual mode (e.g. "vim -S script.vim"), the "-- VISUAL --" mode message sometimes doesn't appear. This happens because skip_showmode() calls char_avail(), which reads raw terminal input and picks up terminal response escape sequences (e.g. t_RV response). Combined with !KeyTyped (which is TRUE after script execution), this causes skip_showmode() to return TRUE, preventing the mode from being displayed. Fix this by checking only the stuff buffer and typeahead buffer for pending characters, instead of char_avail() which also reads raw terminal input. This way, terminal response sequences no longer interfere with mode display. fixes: #16620 closes: #19801 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Christian Brabandt <cb@256bit.org> Signed-off-by: Hirohito Higashi <h.east.727@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 25f6539 commit 9a2260d

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/screen.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4417,17 +4417,20 @@ screen_del_lines(
44174417

44184418
/*
44194419
* Return TRUE when postponing displaying the mode message: when not redrawing
4420-
* or inside a mapping.
4420+
* or inside a mapping or a script.
44214421
*/
44224422
int
44234423
skip_showmode(void)
44244424
{
4425-
// Call char_avail() only when we are going to show something, because it
4426-
// takes a bit of time. redrawing() may also call char_avail().
4425+
// Check the stuff buffer, typeahead buffer and script input for pending
4426+
// characters, instead of char_avail() which also reads raw terminal input
4427+
// and may pick up terminal response sequences (e.g. t_RV response),
4428+
// falsely preventing the mode from being shown.
44274429
if (global_busy
44284430
|| msg_silent != 0
44294431
|| !redrawing()
4430-
|| (char_avail() && !KeyTyped))
4432+
|| ((!stuff_empty() || typebuf.tb_len > 0 || using_script())
4433+
&& !KeyTyped))
44314434
{
44324435
redraw_mode = TRUE; // show mode later
44334436
return TRUE;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ static char *(features[]) =
734734

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
238,
737739
/**/
738740
237,
739741
/**/

0 commit comments

Comments
 (0)