[PR #15935] ConPTY: Avoid WINDOW_BUFFER_SIZE_EVENT when the viewport moves #30784

Open
opened 2026-01-31 09:42:55 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/15935

State: closed
Merged: Yes


SetConsoleWindowInfoImpl calls PostUpdateWindowSize, which emits a
CM_SET_WINDOW_SIZE event, which causes _InternalSetWindowSize to be
called, which calls ScreenBufferSizeChange which then finally emits a
WINDOW_BUFFER_SIZE_EVENT event into the client input buffer.

This messes up applications like which make use of
WINDOW_BUFFER_SIZE_EVENT to perform potentially lossy operations.
In case of SSH this results in a resize (SIGWINCH) of the server-side
screen which similarly may result in a response by the shell, etc.
Since that happens over networks and is async, and because our conhost
VT viewport implementation appears to have a number of subtle bugs,
this results in duplicate output lines (sometimes hundreds).

Under Windows Terminal this issue is not as apparent, since ConPTY has
no viewport that can be moved and no scrollback. It only appears as an
issue if a terminal application reacts poorly to the SIGWINCH event.

Closes #15769

Validation Steps Performed

  • Set a breakpoint in SynthesizeWindowBufferSizeEvent
  • Launch WSL and cause the viewport to move down
    No calls to SynthesizeWindowBufferSizeEvent
  • Execute tput reset
    Input line moves to row 0
**Original Pull Request:** https://github.com/microsoft/terminal/pull/15935 **State:** closed **Merged:** Yes --- `SetConsoleWindowInfoImpl` calls `PostUpdateWindowSize`, which emits a `CM_SET_WINDOW_SIZE` event, which causes `_InternalSetWindowSize` to be called, which calls `ScreenBufferSizeChange` which then finally emits a `WINDOW_BUFFER_SIZE_EVENT` event into the client input buffer. This messes up applications like which make use of `WINDOW_BUFFER_SIZE_EVENT` to perform potentially lossy operations. In case of SSH this results in a resize (SIGWINCH) of the server-side screen which similarly may result in a response by the shell, etc. Since that happens over networks and is async, and because our conhost VT viewport implementation appears to have a number of subtle bugs, this results in duplicate output lines (sometimes hundreds). Under Windows Terminal this issue is not as apparent, since ConPTY has no viewport that can be moved and no scrollback. It only appears as an issue if a terminal application reacts poorly to the SIGWINCH event. Closes #15769 ## Validation Steps Performed * Set a breakpoint in `SynthesizeWindowBufferSizeEvent` * Launch WSL and cause the viewport to move down No calls to `SynthesizeWindowBufferSizeEvent` ✅ * Execute `tput reset` Input line moves to row 0 ✅
claunia added the pull-request label 2026-01-31 09:42:55 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#30784