Conhost window padding is filled with the wrong color #16180

Closed
opened 2026-01-31 04:59:57 +00:00 by claunia · 4 comments
Owner

Originally created by @j4james on GitHub (Dec 16, 2021).

Windows Terminal version

Commit 8dfdfc4d61

Windows build number

10.0.19041.1348

Other Software

No response

Steps to reproduce

  1. Open a cmd shell in conhost.
  2. Execute the following command: echo ^[[41m (where ^[ is Ctrl+[).
  3. Resize the window, making it just a few pixels wider and higher, but not enough to extend the number of columns or rows (we don't want to trigger a reflow of the buffer).

Expected Behavior

I'd expect the additional window padding to be filled with the default background color (black in this case).

Actual Behavior

The window padding is filled with the current background color (red in this case).

image

On my inbox version of conhost, only the bottom padding is filled in red - the screenshot above is from a recent OpenConsole build. But in my opinion, none of that padding area should be red, so both of them are wrong.

The problem, as I understand it, is that the implementation of the GetDefaultBrushColors method, which in conhost returns the active attributes rather than the default attributes.

bb71179a24/src/host/renderData.cpp (L110-L114)

These attributes are then used in the renderer when initializing the default brushes in the _UpdateDrawingBrushes call.

dacff61f88/src/renderer/base/renderer.cpp (L145)

And in the GDI render engine, the default brushes are used to set the DC brush color and the hung app painting color.

95cc7d9625/src/renderer/gdi/state.cpp (L300-L307)

I'm almost certain that this is a mistake, though, and we should just be using the default attributes (i.e. TextAttribute{}). This is already the case in the Windows Terminal implementation of GetDefaultBrushColors.

bb71179a24/src/cascadia/TerminalCore/terminalrenderdata.cpp (L45-L48)

And if we're going to be doing that everywhere, we could actually just get rid of the GetDefaultBrushColors method altogether.

Originally created by @j4james on GitHub (Dec 16, 2021). ### Windows Terminal version Commit 8dfdfc4d6178baca8cd966167fbe6bc78b1fe7b7 ### Windows build number 10.0.19041.1348 ### Other Software _No response_ ### Steps to reproduce 1. Open a cmd shell in conhost. 2. Execute the following command: `echo ^[[41m` (where `^[` is <kbd>Ctrl</kbd>+<kbd>[</kbd>). 3. Resize the window, making it just a few pixels wider and higher, but not enough to extend the number of columns or rows (we don't want to trigger a reflow of the buffer). ### Expected Behavior I'd expect the additional window padding to be filled with the default background color (black in this case). ### Actual Behavior The window padding is filled with the current background color (red in this case). ![image](https://user-images.githubusercontent.com/4181424/146431097-16b2ddda-f1a4-45aa-b871-6591202c91c1.png) On my inbox version of conhost, only the bottom padding is filled in red - the screenshot above is from a recent OpenConsole build. But in my opinion, none of that padding area should be red, so both of them are wrong. The problem, as I understand it, is that the implementation of the `GetDefaultBrushColors` method, which in conhost returns the active attributes rather than the default attributes. https://github.com/microsoft/terminal/blob/bb71179a24ff186eab999676732afff8a345cc12/src/host/renderData.cpp#L110-L114 These attributes are then used in the renderer when initializing the default brushes in the `_UpdateDrawingBrushes` call. https://github.com/microsoft/terminal/blob/dacff61f8862fa7c28f0244e74555cb2658455ad/src/renderer/base/renderer.cpp#L145 And in the GDI render engine, the default brushes are used to set the DC brush color and the hung app painting color. https://github.com/microsoft/terminal/blob/95cc7d96257c4e7fb81fadee1e4a8e434a690be0/src/renderer/gdi/state.cpp#L300-L307 I'm almost certain that this is a mistake, though, and we should just be using the default attributes (i.e. `TextAttribute{}`). This is already the case in the Windows Terminal implementation of `GetDefaultBrushColors`. https://github.com/microsoft/terminal/blob/bb71179a24ff186eab999676732afff8a345cc12/src/cascadia/TerminalCore/terminalrenderdata.cpp#L45-L48 And if we're going to be doing that everywhere, we could actually just get rid of the `GetDefaultBrushColors` method altogether.
claunia added the Product-ConhostResolution-Fix-CommittedPriority-3Needs-Tag-Fix labels 2026-01-31 04:59:58 +00:00
Author
Owner

@DHowett commented on GitHub (Dec 16, 2021):

Wow, we definitely shouldn't do that. I wonder when we regressed...

@DHowett commented on GitHub (Dec 16, 2021): Wow, we definitely shouldn't do that. I wonder when we regressed...
Author
Owner

@j4james commented on GitHub (Dec 16, 2021):

It looks to me like it's been this way since the first open source release. I think the only change has been the red now showing on the right hand side as well as the bottom, I suspect because the renderer wasn't clipping correctly at one point.

You likely wouldn't have noticed the issue in the legacy v1 console because it only sized on exact character boundaries, so the margin area probably never showed.

Are there any objections to me submitting a PR to nuke the GetDefaultBrushColors method?

@j4james commented on GitHub (Dec 16, 2021): It looks to me like it's been this way since the first open source release. I think the only change has been the red now showing on the right hand side as well as the bottom, I suspect because the renderer wasn't clipping correctly at one point. You likely wouldn't have noticed the issue in the legacy v1 console because it only sized on exact character boundaries, so the margin area probably never showed. Are there any objections to me submitting a PR to nuke the `GetDefaultBrushColors` method?
Author
Owner

@DHowett commented on GitHub (Dec 16, 2021):

Please do! No objections at all to the removal of code that reminds us of The Bad Old Days ™️

@DHowett commented on GitHub (Dec 16, 2021): Please do! No objections at all to the removal of code that reminds us of The Bad Old Days ™️
Author
Owner

@ghost commented on GitHub (Feb 3, 2022):

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

Handy links:

@ghost commented on GitHub (Feb 3, 2022): :tada:This issue was addressed in #11982, which has now been successfully released as `Windows Terminal Preview v1.13.10336.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.13.10336.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#16180