Skip to content

Commit b1cf161

Browse files
committed
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)
1 parent 7ebf4e1 commit b1cf161

2 files changed

Lines changed: 54 additions & 22 deletions

File tree

src/os_win32.c

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3966,6 +3966,48 @@ mch_get_shellsize(void)
39663966
return OK;
39673967
}
39683968

3969+
/*
3970+
* Resize console buffer to 'COORD'
3971+
*/
3972+
static void
3973+
ResizeConBuf(
3974+
HANDLE hConsole,
3975+
COORD coordScreen)
3976+
{
3977+
if (!SetConsoleScreenBufferSize(hConsole, coordScreen))
3978+
{
3979+
#ifdef MCH_WRITE_DUMP
3980+
if (fdDump)
3981+
{
3982+
fprintf(fdDump, "SetConsoleScreenBufferSize failed: %lx\n",
3983+
GetLastError());
3984+
fflush(fdDump);
3985+
}
3986+
#endif
3987+
}
3988+
}
3989+
3990+
/*
3991+
* Resize console window size to 'srWindowRect'
3992+
*/
3993+
static void
3994+
ResizeWindow(
3995+
HANDLE hConsole,
3996+
SMALL_RECT srWindowRect)
3997+
{
3998+
if (!SetConsoleWindowInfo(hConsole, TRUE, &srWindowRect))
3999+
{
4000+
#ifdef MCH_WRITE_DUMP
4001+
if (fdDump)
4002+
{
4003+
fprintf(fdDump, "SetConsoleWindowInfo failed: %lx\n",
4004+
GetLastError());
4005+
fflush(fdDump);
4006+
}
4007+
#endif
4008+
}
4009+
}
4010+
39694011
/*
39704012
* Set a console window to `xSize' * `ySize'
39714013
*/
@@ -4019,32 +4061,20 @@ ResizeConBufAndWindow(
40194061
}
40204062
}
40214063

4022-
if (!SetConsoleWindowInfo(g_hConOut, TRUE, &srWindowRect))
4023-
{
4024-
#ifdef MCH_WRITE_DUMP
4025-
if (fdDump)
4026-
{
4027-
fprintf(fdDump, "SetConsoleWindowInfo failed: %lx\n",
4028-
GetLastError());
4029-
fflush(fdDump);
4030-
}
4031-
#endif
4032-
}
4033-
4034-
/* define the new console buffer size */
4064+
// define the new console buffer size
40354065
coordScreen.X = xSize;
40364066
coordScreen.Y = ySize;
40374067

4038-
if (!SetConsoleScreenBufferSize(hConsole, coordScreen))
4068+
// In the new console call API in reverse order
4069+
if (!vtp_working)
40394070
{
4040-
#ifdef MCH_WRITE_DUMP
4041-
if (fdDump)
4042-
{
4043-
fprintf(fdDump, "SetConsoleScreenBufferSize failed: %lx\n",
4044-
GetLastError());
4045-
fflush(fdDump);
4046-
}
4047-
#endif
4071+
ResizeWindow(hConsole, srWindowRect);
4072+
ResizeConBuf(hConsole, coordScreen);
4073+
}
4074+
else
4075+
{
4076+
ResizeConBuf(hConsole, coordScreen);
4077+
ResizeWindow(hConsole, srWindowRect);
40484078
}
40494079
}
40504080

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,8 @@ static char *(features[]) =
794794

795795
static int included_patches[] =
796796
{ /* Add new patch number below this line */
797+
/**/
798+
250,
797799
/**/
798800
249,
799801
/**/

0 commit comments

Comments
 (0)