SetConsoleWindowInfo(...) corrupts output buffer #8874

Closed
opened 2026-01-31 01:40:11 +00:00 by claunia · 3 comments
Owner

Originally created by @vladdeSV on GitHub (Jun 7, 2020).

When resizing the screen with C++ function SetConsoleWindowInfo(...); the screen (the buffer?) becomes "corrupted" (see screenshots below).

Environment

Windows build number: 10.0.18363.0
Windows Terminal version: 1.0.1401.0

Steps to reproduce

  1. Compile following C++ code (taken from #5843, but same code applies)
#include "pch.h"
#include <windows.h> 

int main()
{
	HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
	SMALL_RECT srNewWinSize;
	srNewWinSize.Top = 1;
	srNewWinSize.Left = 1;
	srNewWinSize.Right = 40;
	srNewWinSize.Bottom = 20;
	SetConsoleWindowInfo(hStdOut, TRUE, &srNewWinSize);
}
  1. Run the application with Windows Terminal using Powershell or CMD.exe
  • if CMD.exe
    • after running program first time, the dot character . does not display.
    • after running program tree or four times (would sometimes vary during testing I believe), the screen becomes "corrupted", where the size of the window is same as before, but the buffer is not. if holding backspace, cursor moves up one line
  • if Powershell, it crashes. See screenshot
  1. The screen becomes corrupted

Expected behavior

The terminal should resize, just as when done when running cmd.exe and powershell.exe individually

cmd.exe resize powershell.exe resize

Actual behavior

These crashes occur if the shell is run from inside Windows Terminal, and not when opening powershell.exe or cmd.exe.

Screenshot

CMD, in this screenshot I ran the program 4 times, then held the s key until it looped the buffer. If I held backspace the cursor would move up and down the buffer.
cmd resize

Powershell 7 (preview), crashes after running the program and pressing one button, then prompts to open issue in their repo. I don't think that is appropriate here, but am open for suggestion.
cmd resize

Originally created by @vladdeSV on GitHub (Jun 7, 2020). When resizing the screen with C++ function `SetConsoleWindowInfo(...);` the screen (the buffer?) becomes "corrupted" (see screenshots below). # Environment ```none Windows build number: 10.0.18363.0 Windows Terminal version: 1.0.1401.0 ``` # Steps to reproduce 1. Compile following C++ code (taken from #5843, but same code applies) ```c++ #include "pch.h" #include <windows.h> int main() { HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); SMALL_RECT srNewWinSize; srNewWinSize.Top = 1; srNewWinSize.Left = 1; srNewWinSize.Right = 40; srNewWinSize.Bottom = 20; SetConsoleWindowInfo(hStdOut, TRUE, &srNewWinSize); } ``` 2. Run the application with Windows Terminal using Powershell or CMD.exe - if CMD.exe - after running program first time, the dot character `.` does not display. - after running program tree or four times (would sometimes vary during testing I believe), the screen becomes "corrupted", where the size of the window is same as before, but the buffer is not. if holding backspace, cursor moves up one line - if Powershell, it crashes. See screenshot 3. The screen becomes corrupted # Expected behavior The terminal should resize, just as when done when running `cmd.exe` and `powershell.exe` individually ![cmd.exe resize](https://i.imgur.com/WOCSG2c.png) ![powershell.exe resize](https://i.imgur.com/PRsQJjl.png) # Actual behavior These crashes occur if the shell is run from inside Windows Terminal, and not when opening `powershell.exe` or `cmd.exe`. ### Screenshot **CMD**, in this screenshot I ran the program 4 times, then held the <kbd>s</kbd> key until it looped the buffer. If I held <kbd>backspace</kbd> the cursor would move up *and* down the buffer. ![cmd resize](https://i.imgur.com/LudoegF.png) **Powershell 7 (preview)**, crashes after running the program and pressing one button, then prompts to open issue in their repo. I don't think that is appropriate here, but am open for suggestion. ![cmd resize](https://i.imgur.com/9kJh09C.png)
claunia added the Resolution-Duplicate label 2026-01-31 01:40:11 +00:00
Author
Owner

@j4james commented on GitHub (Jun 7, 2020):

This is essentially covered by issue #5094. The console APIs have no way of communicating a window resize to the Windows Terminal until we support VT resizing sequences there.

@j4james commented on GitHub (Jun 7, 2020): This is essentially covered by issue #5094. The console APIs have no way of communicating a window resize to the Windows Terminal until we support VT resizing sequences there.
Author
Owner

@DHowett commented on GitHub (Jun 7, 2020):

Indeed! /dup #5094. Thanks!

@DHowett commented on GitHub (Jun 7, 2020): Indeed! /dup #5094. Thanks!
Author
Owner

@ghost commented on GitHub (Jun 7, 2020):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Jun 7, 2020): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#8874