New 0.11 VT attributes bug, attributes are not applied to " " (space) cells #8096

Closed
opened 2026-01-31 01:20:40 +00:00 by claunia · 7 comments
Owner

Originally created by @PhMajerus on GitHub (May 12, 2020).

In Windows Terminal 0.11.1251.0, a new VT attributes bug has been introduced.

When output contains VT escape sequences to set text attributes, they are sometimes ignored when the cells contains the space character.

If this sounds a lot like #5502, it is because it's probably exactly the same issue, you need to write spaces not only when the background color is different, but also if some other attributes, such underline are set (and you probably should make sure you include reverse video and crossed-out as well).

Repro command line : curl 'https://raw.githubusercontent.com/PhMajerus/ANSI-art/master/Windows%20Terminal.ans' | sed 'H;$!d;x;s/\x1A.*$//' | iconv -f CP437

image

Compare the top of the "W" with conhost:
image

It seems to be a bit random, even when it's not scrolling the buffer:
image

File used: https://github.com/PhMajerus/ANSI-art/blob/master/Windows%20Terminal.ans

Originally created by @PhMajerus on GitHub (May 12, 2020). In Windows Terminal 0.11.1251.0, a new VT attributes bug has been introduced. When output contains VT escape sequences to set text attributes, they are sometimes ignored when the cells contains the space character. If this sounds a lot like #5502, it is because it's probably exactly the same issue, you need to write spaces not only when the background color is different, but also if some other attributes, such underline are set (and you probably should make sure you include reverse video and crossed-out as well). Repro command line : `curl 'https://raw.githubusercontent.com/PhMajerus/ANSI-art/master/Windows%20Terminal.ans' | sed 'H;$!d;x;s/\x1A.*$//' | iconv -f CP437` ![image](https://user-images.githubusercontent.com/25664275/81724825-4b1d6400-9485-11ea-9f03-41098f687663.png) Compare the top of the "W" with conhost: ![image](https://user-images.githubusercontent.com/25664275/81724934-72743100-9485-11ea-91d8-6e8797578698.png) It seems to be a bit random, even when it's not scrolling the buffer: ![image](https://user-images.githubusercontent.com/25664275/81725053-946db380-9485-11ea-8df3-d09c9468054c.png) File used: https://github.com/PhMajerus/ANSI-art/blob/master/Windows%20Terminal.ans
Author
Owner

@DHowett-MSFT commented on GitHub (May 12, 2020):

@zadjii-msft this is probably related to the HasIdenticalVisualRwpresentationForSpaces comment in the last PR that touched this area. Does it have to wait until after #2661 so we can maintain full fidelity?

@DHowett-MSFT commented on GitHub (May 12, 2020): @zadjii-msft this is probably related to the `HasIdenticalVisualRwpresentationForSpaces` comment in the last PR that touched this area. Does it have to wait until after #2661 so we can maintain full fidelity?
Author
Owner

@DHowett-MSFT commented on GitHub (May 12, 2020):

(Also, love the repro file!)

@DHowett-MSFT commented on GitHub (May 12, 2020): (Also, love the repro file!)
Author
Owner

@zadjii-msft commented on GitHub (May 12, 2020):

oh jeez

uh, I'm not sure at the moment. That sure makes sense. I'm hoping that the check here might be able to be easily adopted to the other attributes as well. since we've got a simple repro, making that into a test shouldn't be too hard

@zadjii-msft commented on GitHub (May 12, 2020): oh jeez uh, I'm not sure at the moment. That sure makes sense. I'm hoping that the [check here](https://github.com/microsoft/terminal/blob/master/src/renderer/vt/XtermEngine.cpp#L478-L482) might be able to be easily adopted to the other attributes as well. since we've got a simple repro, making that into a test shouldn't be _too_ hard
Author
Owner

@j4james commented on GitHub (May 12, 2020):

FYI, I think this could be something that gets fixed by the #2661 PR I've been experimenting with. I had to put that on hold while I got some of the foundational PRs out the way, but I know I got to the point where I was tracking the "last" rendering brush as a TextAttribute, with the intention of replacing all the occurrences of _lastFG and _lastBG. So if the problem is just that the _lastBG attribute is not tracking everything, then that may just end up resolving itself.

@j4james commented on GitHub (May 12, 2020): FYI, I _think_ this could be something that gets fixed by the #2661 PR I've been experimenting with. I had to put that on hold while I got some of the foundational PRs out the way, but I know I got to the point where I was tracking the "last" rendering brush as a `TextAttribute`, with the intention of replacing all the occurrences of `_lastFG` and `_lastBG`. So if the problem is just that the `_lastBG` attribute is not tracking everything, then that may just end up resolving itself.
Author
Owner

@DHowett-MSFT commented on GitHub (May 13, 2020):

Moved into the "want to fix after v1 but before the next major version" milestone 1.x -- it's a bucket right now, but we'll pick it apart.

@DHowett-MSFT commented on GitHub (May 13, 2020): Moved into the "want to fix after v1 but before the next major version" milestone 1.x -- it's a bucket right now, but we'll pick it apart.
Author
Owner

@j4james commented on GitHub (May 14, 2020):

I've just got around to testing this in my POC fix for #2661, and it's already working there (that's without having done anything with the _lastBG and _lastFG references). So I suspect this might just be a duplicate of #3076, which is the result of the old vtengine updating the "meta" attributes before it handled the colors. See here:

7612044363/src/renderer/vt/Xterm256Engine.cpp (L47-L52)

If _UpdateUnderline turned on the underline attribute, but then _RgbUpdateDrawingBrushes decided to reset the colors with an SGR 0 sequence, suddenly your underline gets mistakenly reset as well.

@j4james commented on GitHub (May 14, 2020): I've just got around to testing this in my POC fix for #2661, and it's already working there (that's without having done anything with the `_lastBG` and `_lastFG` references). So I suspect this might just be a duplicate of #3076, which is the result of the old vtengine updating the "meta" attributes before it handled the colors. See here: https://github.com/microsoft/terminal/blob/76120443636a385ed05e6d9304a7932b4023f64e/src/renderer/vt/Xterm256Engine.cpp#L47-L52 If `_UpdateUnderline` turned on the underline attribute, but then `_RgbUpdateDrawingBrushes` decided to reset the colors with an `SGR 0` sequence, suddenly your underline gets mistakenly reset as well.
Author
Owner

@ghost commented on GitHub (Jul 22, 2020):

:tada:This issue was addressed in #6506, which has now been successfully released as Windows Terminal Preview v1.2.2022.0.🎉

Handy links:

@ghost commented on GitHub (Jul 22, 2020): :tada:This issue was addressed in #6506, which has now been successfully released as `Windows Terminal Preview v1.2.2022.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.2.2022.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#8096