patch 9.2.0238: showmode message may not be displayed

Commit: 
https://github.com/vim/vim/commit/9a2260d6cfa1053bdfd8b7febdfdbee1ebf17d12
Author: Hirohito Higashi <[email protected]>
Date:   Tue Mar 24 20:06:05 2026 +0000

    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) <[email protected]>
    Co-authored-by: Christian Brabandt <[email protected]>
    Signed-off-by: Hirohito Higashi <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/screen.c b/src/screen.c
index fa3b3860f..78927c163 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -4417,17 +4417,20 @@ screen_del_lines(
 
 /*
  * Return TRUE when postponing displaying the mode message: when not redrawing
- * or inside a mapping.
+ * or inside a mapping or a script.
  */
     int
 skip_showmode(void)
 {
-    // Call char_avail() only when we are going to show something, because it
-    // takes a bit of time.  redrawing() may also call char_avail().
+    // Check the stuff buffer, typeahead buffer and script input for pending
+    // characters, instead of char_avail() which also reads raw terminal input
+    // and may pick up terminal response sequences (e.g. t_RV response),
+    // falsely preventing the mode from being shown.
     if (global_busy
            || msg_silent != 0
            || !redrawing()
-           || (char_avail() && !KeyTyped))
+           || ((!stuff_empty() || typebuf.tb_len > 0 || using_script())
+               && !KeyTyped))
     {
        redraw_mode = TRUE;             // show mode later
        return TRUE;
diff --git a/src/version.c b/src/version.c
index 412a37bb0..67feb77dd 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    238,
 /**/
     237,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1w589Y-004AUo-Sm%40256bit.org.

Raspunde prin e-mail lui