From b1cf16113f7ab67f42fb6822cecdef74a54fa950 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 7 Aug 2018 20:47:16 +0200 Subject: [PATCH] patch 8.1.0250: MS-Windows using VTP: windows size change incorrect Problem: MS-Windows using VTP: windows size change incorrect. Solution: Call SetConsoleScreenBufferSize() first. (Nobuhiro Takasaki, closes #3164) --- src/os_win32.c | 74 +++++++++++++++++++++++++++++++++++--------------- src/version.c | 2 ++ 2 files changed, 54 insertions(+), 22 deletions(-) diff --git a/src/os_win32.c b/src/os_win32.c index f8884e401..63572350b 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -3966,6 +3966,48 @@ mch_get_shellsize(void) return OK; } +/* + * Resize console buffer to 'COORD' + */ + static void +ResizeConBuf( + HANDLE hConsole, + COORD coordScreen) +{ + if (!SetConsoleScreenBufferSize(hConsole, coordScreen)) + { +#ifdef MCH_WRITE_DUMP + if (fdDump) + { + fprintf(fdDump, "SetConsoleScreenBufferSize failed: %lx\n", + GetLastError()); + fflush(fdDump); + } +#endif + } +} + +/* + * Resize console window size to 'srWindowRect' + */ + static void +ResizeWindow( + HANDLE hConsole, + SMALL_RECT srWindowRect) +{ + if (!SetConsoleWindowInfo(hConsole, TRUE, &srWindowRect)) + { +#ifdef MCH_WRITE_DUMP + if (fdDump) + { + fprintf(fdDump, "SetConsoleWindowInfo failed: %lx\n", + GetLastError()); + fflush(fdDump); + } +#endif + } +} + /* * Set a console window to `xSize' * `ySize' */ @@ -4019,32 +4061,20 @@ ResizeConBufAndWindow( } } - if (!SetConsoleWindowInfo(g_hConOut, TRUE, &srWindowRect)) - { -#ifdef MCH_WRITE_DUMP - if (fdDump) - { - fprintf(fdDump, "SetConsoleWindowInfo failed: %lx\n", - GetLastError()); - fflush(fdDump); - } -#endif - } - - /* define the new console buffer size */ + // define the new console buffer size coordScreen.X = xSize; coordScreen.Y = ySize; - if (!SetConsoleScreenBufferSize(hConsole, coordScreen)) + // In the new console call API in reverse order + if (!vtp_working) { -#ifdef MCH_WRITE_DUMP - if (fdDump) - { - fprintf(fdDump, "SetConsoleScreenBufferSize failed: %lx\n", - GetLastError()); - fflush(fdDump); - } -#endif + ResizeWindow(hConsole, srWindowRect); + ResizeConBuf(hConsole, coordScreen); + } + else + { + ResizeConBuf(hConsole, coordScreen); + ResizeWindow(hConsole, srWindowRect); } } diff --git a/src/version.c b/src/version.c index bb730f4e3..c9b0ec4dc 100644 --- a/src/version.c +++ b/src/version.c @@ -794,6 +794,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 250, /**/ 249, /**/ -- 2.40.0