ConPTY sends two WINDOW_BUFFER_SIZE_EVENT messages when the window is restored from maximize #2471

Open
opened 2026-01-30 22:55:55 +00:00 by claunia · 1 comment
Owner

Originally created by @zadjii-msft on GitHub (Jul 1, 2019).

I think I found one resize bug. A ConPTY sends two WINDOW_BUFFER_SIZE_EVENT messages when the window is restored from maximize, but the first one has the wrong size (not sure of the internals of this, but it appears in conhost/tmux/pwsh, alacritty/pwsh, and Windows Terminal).

Run this program as conevents -es in conhost and a different terminal to see the difference; maximize and restore the window. For example, restoring the WinTerm window reports 119 x 46 in the WINDOW_BUFFER_SIZE_EVENT message, but GetConsoleScreenBufferInfo returns the correct value 119 x 32.

Originally posted by @parkovski in https://github.com/microsoft/terminal/issues/1465#issuecomment-506924361

Originally created by @zadjii-msft on GitHub (Jul 1, 2019). I think I found one resize bug. A ConPTY sends two `WINDOW_BUFFER_SIZE_EVENT` messages when the window is restored from maximize, but the first one has the wrong size (not sure of the internals of this, but it appears in conhost/tmux/pwsh, alacritty/pwsh, and Windows Terminal). Run [this program](https://github.com/parkovski/conutils/blob/master/conevents.cpp) as `conevents -es` in conhost and a different terminal to see the difference; maximize and restore the window. For example, restoring the WinTerm window reports `119 x 46` in the `WINDOW_BUFFER_SIZE_EVENT` message, but `GetConsoleScreenBufferInfo` returns the correct value `119 x 32`. _Originally posted by @parkovski in https://github.com/microsoft/terminal/issues/1465#issuecomment-506924361_
claunia added the Issue-BugPriority-3Area-ServerProduct-Conpty labels 2026-01-30 22:55:56 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Jul 29, 2019):

Holy crap, I saw the cause of this in https://github.com/microsoft/terminal/issues/1795#issuecomment-516014782.

We perform a resize on the conpty buffer twice, once to resize the width, and again to resize the height. By resizing twice, we hit the code path that emits a WINDOW_BUFFER_SIZE_EVENT twice. This is obviously insane, so there's gotta be a better way.

@zadjii-msft commented on GitHub (Jul 29, 2019): Holy crap, I saw the cause of this in https://github.com/microsoft/terminal/issues/1795#issuecomment-516014782. We perform a resize on the conpty buffer twice, once to resize the width, and again to resize the height. By resizing _twice_, we hit the code path that emits a `WINDOW_BUFFER_SIZE_EVENT` twice. This is obviously insane, so there's gotta be a better way.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#2471