changeset 31805:e279b756475b v9.0.1235

patch 9.0.1235: MS-Windows console: not flushing termguicolors Commit: https://github.com/vim/vim/commit/dc7179f9a4cc74d864d1f6414e691d25bac8f831 Author: Christopher Plewright <chris@createng.com> Date: Mon Jan 23 12:33:23 2023 +0000 patch 9.0.1235: MS-Windows console: not flushing termguicolors Problem: MS-Windows console: not flushing termguicolors. Solution: Flush termguicolors. (Christopher Plewright, closes https://github.com/vim/vim/issues/11871)
author Bram Moolenaar <Bram@vim.org>
date Mon, 23 Jan 2023 13:45:07 +0100
parents 50555279168b
children 885c61178118
files src/os_win32.c src/proto/os_win32.pro src/term.c src/version.c
diffstat 4 files changed, 20 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -6776,20 +6776,30 @@ visual_bell(void)
     WORD    attrFlash = ~g_attrCurrent & 0xff;
 
     DWORD   dwDummy;
-    LPWORD  oldattrs = ALLOC_MULT(WORD, Rows * Columns);
-
-    if (oldattrs == NULL)
-	return;
-    ReadConsoleOutputAttribute(g_hConOut, oldattrs, Rows * Columns,
+    LPWORD  oldattrs = NULL;
+
+# ifdef FEAT_TERMGUICOLORS
+    if (!(p_tgc || t_colors >= 256))
+# endif
+    {
+	oldattrs = ALLOC_MULT(WORD, Rows * Columns);
+	if (oldattrs == NULL)
+	    return;
+	ReadConsoleOutputAttribute(g_hConOut, oldattrs, Rows * Columns,
 			       coordOrigin, &dwDummy);
+    }
+
     FillConsoleOutputAttribute(g_hConOut, attrFlash, Rows * Columns,
 			       coordOrigin, &dwDummy);
 
     Sleep(15);	    // wait for 15 msec
-    if (!vtp_working)
+
+    if (oldattrs != NULL)
+    {
 	WriteConsoleOutputAttribute(g_hConOut, oldattrs, Rows * Columns,
 				coordOrigin, &dwDummy);
-    vim_free(oldattrs);
+	vim_free(oldattrs);
+    }
 }
 
 
@@ -8665,12 +8675,6 @@ wt_init(void)
     wt_working = mch_getenv("WT_SESSION") != NULL;
 }
 
-    int
-use_wt(void)
-{
-    return USE_WT;
-}
-
 # ifdef FEAT_TERMGUICOLORS
     static int
 ctermtoxterm(
--- a/src/proto/os_win32.pro
+++ b/src/proto/os_win32.pro
@@ -73,7 +73,6 @@ void set_alist_count(void);
 void fix_arg_enc(void);
 int mch_setenv(char *var, char *value, int x);
 int vtp_printf(char *format, ...);
-int use_wt(void);
 void get_default_console_color(int *cterm_fg, int *cterm_bg, guicolor_T *gui_fg, guicolor_T *gui_bg);
 void control_console_color_rgb(void);
 int use_vtp(void);
--- a/src/term.c
+++ b/src/term.c
@@ -3222,7 +3222,7 @@ term_rgb_color(char_u *s, guicolor_T rgb
     vim_snprintf(buf, MAX_COLOR_STR_LEN,
 				  (char *)s, RED(rgb), GREEN(rgb), BLUE(rgb));
 #ifdef FEAT_VTP
-    if (use_wt())
+    if (use_vtp() && (p_tgc || t_colors >= 256))
     {
 	out_flush();
 	buf[1] = '[';
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1235,
+/**/
     1234,
 /**/
     1233,