]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0200: term: DECRQM codes are sent too early v9.2.0200
authorFoxe Chen <chen.foxe@gmail.com>
Thu, 19 Mar 2026 19:10:32 +0000 (19:10 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 19 Mar 2026 19:19:30 +0000 (19:19 +0000)
Problem:  term: DECRQM codes are sent too early, the resulting DECRPM
          responses can arrive after Vim has already exited, leaking
          into the shell's input buffer (Christian Brabandt).
Solution: Only send DECRQM codes once termcap_active is set
          (Foxe Chen).

related: #19660
fixes:   #19660#issuecomment-4085448070
closes:  #19748

Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/main.c
src/proto/term.pro
src/term.c
src/version.c

index 9f9fd1205e63bb7e86dc6809fa67f6d76e6b8646..b5f542a496b4ea50ea8654ee3f347836a544795b 100644 (file)
@@ -893,6 +893,9 @@ vim_main2(void)
 
     may_req_bg_color();
 # endif
+    // Same reason for termresponse, don't want the terminal sending out the
+    // DECRPM response after Vim has exited.
+    send_decrqm_modes();
 
     // start in insert mode
     if (p_im)
index 9653a35af3bce9fec1998e144614f303815e713a..82c794f4f9ad51c286d636fe765fffcef6b5d000 100644 (file)
@@ -96,6 +96,7 @@ void swap_tcap(void);
 void ansi_color2rgb(int nr, char_u *r, char_u *g, char_u *b, char_u *ansi_idx);
 void cterm_color2rgb(int nr, char_u *r, char_u *g, char_u *b, char_u *ansi_idx);
 int term_replace_keycodes(char_u *ta_buf, int ta_len, int len_arg);
+void send_decrqm_modes(void);
 void term_disable_dec(void);
 void term_set_win_resize(bool state);
 void term_set_sync_output(int flags);
index e9cb91cdcd9b4da067ea71a582d406ae12e9d8bb..5e19b09a92df6fa07eb3d29fa747357c92376e01 100644 (file)
@@ -4051,16 +4051,6 @@ starttermcap(void)
        out_str(T_FE);
 #endif
 
-    if (cur_tmode == TMODE_RAW)
-    {
-       // Request setting of relevant DEC modes via DECRQM
-       for (int i = 0; i < (int)ARRAY_LENGTH(dec_modes); i++)
-       {
-           vim_snprintf((char *)IObuff, IOSIZE, "\033[?%d$p", dec_modes[i]);
-           out_str(IObuff);
-       }
-    }
-
     out_flush();
     termcap_active = TRUE;
     screen_start();                    // don't know where cursor is now
@@ -7981,6 +7971,23 @@ term_replace_keycodes(char_u *ta_buf, int ta_len, int len_arg)
     return len;
 }
 
+/*
+ * Query the settings for the DEC modes we support
+ */
+    void
+send_decrqm_modes(void)
+{
+    if (termcap_active && cur_tmode == TMODE_RAW)
+    {
+       // Request setting of relevant DEC modes via DECRQM
+       for (int i = 0; i < (int)ARRAY_LENGTH(dec_modes); i++)
+       {
+           vim_snprintf((char *)IObuff, IOSIZE, "\033[?%d$p", dec_modes[i]);
+           out_str(IObuff);
+       }
+    }
+}
+
 /*
  * Should be called when cleaning up terminal state.
  */
index a82c17186e8086517355c137394f81b00a6035b6..b1088289fb1c25d998634dfff7475fd51659f127 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    200,
 /**/
     199,
 /**/