ANSI/VT bleeds through empty spaces on right when resizing console with wrap on resize enabled #90

Open
opened 2026-01-30 21:42:07 +00:00 by claunia · 0 comments
Owner

Originally created by @bitcrazed on GitHub (Feb 16, 2018).

From @PhMajerus on October 26, 2017 15:29

Concerns Redstone 3 RTW / Windows 10 ver. 1709, tested on build 16299.19. Affects all WSL distros and more broadly, all Win32 CUI apps using VT.

VT text properties let us control the colors and other text attributes such as underline in-band.
When "Wrap on resize" is enabled, conhost automatically modifies the text buffer when the window is resized to reflow text, and, if necessary, padding lines with spaces until the '\n' is encountered.

The problem is when it pads with spaces, it applies the attributes of the last non-whitespace character of the line to them, instead of the attributes in effect after the last character.
This has the effect of extending colors, underline,... to the end of the line.
It should instead apply the attributes as per the state of the VT parser at that insertion point, which is often different as many scripts output "closing" VT sequences just before a \n or a whitespace.

This screenshot shows the issue using bash, both sets of lines should look exactly the same, but the window has been resized between the two commands, making the attributes of the "Line1" bleed through to the end of the line in the first set.
Note the "\e[m" explicitly stops the dark red background and underline, so applying it to padding spaces isn't up to interpretation, these attributes stop after the character '1'.
wraponresize bug

Even adding a whitespace after "\e[m" exhibits the same issue, so conhost seems to be grabbing the text attributes of the last non-whitepace character of the line when processing the wrap-on-resize.

Copied from original issue: Microsoft/WSL#2607

Originally created by @bitcrazed on GitHub (Feb 16, 2018). _From @PhMajerus on October 26, 2017 15:29_ Concerns Redstone 3 RTW / Windows 10 ver. 1709, tested on build 16299.19. Affects all WSL distros and more broadly, all Win32 CUI apps using VT. VT text properties let us control the colors and other text attributes such as underline in-band. When "Wrap on resize" is enabled, conhost automatically modifies the text buffer when the window is resized to reflow text, and, if necessary, padding lines with spaces until the '\n' is encountered. The problem is when it pads with spaces, it applies the attributes of the last non-whitespace character of the line to them, instead of the attributes in effect after the last character. This has the effect of extending colors, underline,... to the end of the line. It should instead apply the attributes as per the state of the VT parser at that insertion point, which is often different as many scripts output "closing" VT sequences just before a \n or a whitespace. This screenshot shows the issue using bash, both sets of lines should look exactly the same, but the window has been resized between the two commands, making the attributes of the "Line1" bleed through to the end of the line in the first set. Note the "\e[m" explicitly stops the dark red background and underline, so applying it to padding spaces isn't up to interpretation, these attributes stop after the character '1'. ![wraponresize bug](https://user-images.githubusercontent.com/25664275/32061781-e1c34dba-ba72-11e7-921c-5c7fb15ca8a1.png) Even adding a whitespace after "\e[m" exhibits the same issue, so conhost seems to be grabbing the text attributes of the last non-whitepace character of the line when processing the wrap-on-resize. _Copied from original issue: Microsoft/WSL#2607_
claunia added the Product-ConhostWork-ItemResolution-Duplicate labels 2026-01-30 21:42:07 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#90