From c8b126d70d567269464fd70c54e22fdd78ec50ad Mon Sep 17 00:00:00 2001 From: Christopher Plewright Date: Thu, 22 Dec 2022 13:45:23 +0000 Subject: [PATCH] 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) --- src/os_win32.c | 19 +++++++++++-------- src/version.c | 2 ++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/os_win32.c b/src/os_win32.c index 20ec8adeb..4b23b1d1c 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -256,7 +256,8 @@ static int suppress_winsize = 1; // don't fiddle with console 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 @@ PlatformId(void) || 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 @@ SaveConsoleBuffer( // 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 @@ RestoreConsoleBuffer( // 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 @@ termcap_mode_start(void) // 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 @@ termcap_mode_end(void) // 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 @@ vtp_init(void) 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..58bdee4c1 100644 --- a/src/version.c +++ b/src/version.c @@ -695,6 +695,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1086, /**/ 1085, /**/ -- 2.40.0