patch 9.0.1086: display wrong in Windows terminal after exiting Vim
Problem: Display wrong in Windows terminal after exiting Vim.
Solution: Apply screen restore fix for Windows 11 also to Windows 10 builds.
(Christopher Plewright, closes #11713, closes #11706)
diff --git a/src/os_win32.c b/src/os_win32.c
index 20ec8ad..4b23b1d 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -256,7 +256,8 @@
static char_u *exe_path = NULL;
static BOOL win8_or_later = FALSE;
-static BOOL win11_or_later = FALSE;
+static BOOL win10_22H2_or_later = FALSE;
+static BOOL use_alternate_screen_buffer = FALSE;
/*
* Get version number including build number
@@ -919,9 +920,9 @@
|| ovi.dwMajorVersion > 6)
win8_or_later = TRUE;
- if ((ovi.dwMajorVersion == 10 && ovi.dwBuildNumber >= 22000)
+ if ((ovi.dwMajorVersion == 10 && ovi.dwBuildNumber >= 19045)
|| ovi.dwMajorVersion > 10)
- win11_or_later = TRUE;
+ win10_22H2_or_later = TRUE;
#ifdef HAVE_ACL
// Enable privilege for getting or setting SACLs.
@@ -3040,7 +3041,7 @@
// VTP uses alternate screen buffer.
// No need to save buffer contents for restoration.
- if (win11_or_later && vtp_working)
+ if (use_alternate_screen_buffer)
return TRUE;
/*
@@ -3138,7 +3139,7 @@
// VTP uses alternate screen buffer.
// No need to restore buffer contents.
- if (win11_or_later && vtp_working)
+ if (use_alternate_screen_buffer)
return TRUE;
if (cb == NULL || !cb->IsValid)
@@ -6106,7 +6107,8 @@
// VTP uses alternate screen buffer.
// Switch to a new alternate screen buffer.
- if (win11_or_later && p_rs && vtp_working)
+ // But, not if running in a nested terminal
+ if (use_alternate_screen_buffer)
vtp_printf("\033[?1049h");
SaveConsoleBuffer(&g_cbNonTermcap);
@@ -6189,7 +6191,7 @@
// VTP uses alternate screen buffer.
// Switch back to main screen buffer.
- if (exiting && win11_or_later && p_rs && vtp_working)
+ if (exiting && use_alternate_screen_buffer)
vtp_printf("\033[?1049l");
if (!USE_WT && (p_rs || exiting))
@@ -8392,7 +8394,8 @@
default_console_color_fg = fg;
}
# endif
-
+ use_alternate_screen_buffer = win10_22H2_or_later && p_rs && vtp_working
+ && !mch_getenv("VIM_TERMINAL");
set_console_color_rgb();
}
diff --git a/src/version.c b/src/version.c
index 4a3718d69..58bdee4 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1086,
+/**/
1085,
/**/
1084,