vim Background Color Not Always Displaying Correctly (but works in conhost.exe) #16283

Closed
opened 2026-01-31 05:02:43 +00:00 by claunia · 9 comments
Owner

Originally created by @matrdr on GitHub (Dec 27, 2021).

Windows Terminal version

1.11.3471.0

Windows build number

10.0.19044.0

Other Software

vim 8.1 (inside WSL)

Steps to reproduce

Open vim in WSL. A background color different to the terminal's background color shall be set (e.g. by using a colorscheme).
When trying the command :ls or :hi it is visible that the terminal's background color is visible in places where it should not be.

When trying to reproduce this using conhost.exe (the good old terminal) instead of Windows Terminal you may notice that the background works as expected there. Therefore it seems that something is handled differently in Windows Terminal.

Expected Behavior

image

Actual Behavior

image

Originally created by @matrdr on GitHub (Dec 27, 2021). ### Windows Terminal version 1.11.3471.0 ### Windows build number 10.0.19044.0 ### Other Software vim 8.1 (inside WSL) ### Steps to reproduce Open `vim` in WSL. A background color different to the terminal's background color shall be set (e.g. by using a colorscheme). When trying the command `:ls` or `:hi` it is visible that the terminal's background color is visible in places where it should not be. When trying to reproduce this using `conhost.exe` (the good old terminal) instead of Windows Terminal you may notice that the background works as expected there. Therefore it seems that something is handled differently in Windows Terminal. ### Expected Behavior ![image](https://user-images.githubusercontent.com/45005058/147497687-fc67d7c1-b7e4-4bde-b64c-bf41a92b441d.png) ### Actual Behavior ![image](https://user-images.githubusercontent.com/45005058/147497707-b1d47d28-7c7e-445f-988b-b29d3e23256f.png)
Author
Owner

@zadjii-msft commented on GitHub (Jan 3, 2022):

Hmmmm. I'm guessing that you've got the background color in conhost set to the white color scheme entry, right? Conhost (traditionally) only allowed users to set the background color to one of the 16 colors of the color scheme. The Terminal however, more correctly emulates a real terminal, and has a separate color entry for the "default background color", which is defaulted to a black color.

You can probably get the Terminal to look like you're old conhost window by setting defaultBackground to #ffffff or something similar. Either set it just for your WSL profile, or in the profiles.defaults block

@zadjii-msft commented on GitHub (Jan 3, 2022): Hmmmm. I'm guessing that you've got the background color in conhost set to the white color scheme entry, right? Conhost (traditionally) only allowed users to set the background color to one of the 16 colors of the color scheme. The Terminal however, more correctly emulates a real terminal, and has a separate color entry for the "default background color", which is defaulted to a black color. You can probably get the Terminal to look like you're old conhost window by setting `defaultBackground` to `#ffffff` or something similar. Either set it just for your WSL profile, or in the `profiles.defaults` block
Author
Owner

@matrdr commented on GitHub (Jan 3, 2022):

In both cases the default background color is black. It is overridden by an option in vim, which seems to be interpreted differently in both terminals.

@matrdr commented on GitHub (Jan 3, 2022): In both cases the default background color is black. It is overridden by an option in vim, which seems to be interpreted differently in both terminals.
Author
Owner

@zadjii-msft commented on GitHub (Jan 3, 2022):

It is overridden by an option in vim, which seems to be interpreted differently in both terminals.

which option exactly?

@zadjii-msft commented on GitHub (Jan 3, 2022): > It is overridden by an option in vim, which seems to be interpreted differently in both terminals. which option exactly?
Author
Owner

@matrdr commented on GitHub (Jan 3, 2022):

For this example I used the :colorscheme morning command in vim to change its colorscheme. I do not exactly know, what this sets in the terminal.

@matrdr commented on GitHub (Jan 3, 2022): For this example I used the `:colorscheme morning` command in vim to change its colorscheme. I do not exactly know, what this sets in the terminal.
Author
Owner

@j4james commented on GitHub (Jan 3, 2022):

I think the is because the Windows Terminal VT implementation doesn't handle bce (background color erase) correctly for line feeds at the bottom of the screen.

If you look at the debug tap for this, it's outputting line feeds to make space for the two lines after ls, expecting them to be filled with the active background color. But Windows Terminal doesn't do that.

I'm almost sure we already have an issue for this somewhere.

@j4james commented on GitHub (Jan 3, 2022): I think the is because the Windows Terminal VT implementation doesn't handle bce (background color erase) correctly for line feeds at the bottom of the screen. If you look at the debug tap for this, it's outputting line feeds to make space for the two lines after `ls`, expecting them to be filled with the active background color. But Windows Terminal doesn't do that. I'm almost sure we already have an issue for this somewhere.
Author
Owner

@j4james commented on GitHub (Jan 3, 2022):

The issue I was thinking of is #11867, but I suspect there are others as well. I just tried hacking an update to Terminal::_AdjustCursorPosition which fills the new line when scrolling, and that seemed to fix both #11867 and this issue.

@j4james commented on GitHub (Jan 3, 2022): The issue I was thinking of is #11867, but I suspect there are others as well. I just tried hacking an update to `Terminal::_AdjustCursorPosition` which fills the new line when scrolling, and that seemed to fix both #11867 and this issue.
Author
Owner

@DHowett commented on GitHub (Jan 4, 2022):

I owe you all the act of going back and deduplicating all these bugs. Thanks @j4james 😄

@DHowett commented on GitHub (Jan 4, 2022): I owe you all the act of going back and deduplicating all these bugs. Thanks @j4james :smile:
Author
Owner

@zadjii-msft commented on GitHub (Mar 1, 2022):

We believe this was fixed in Terminal v1.13, in #11982. @matrdr would you mind confirming?

@zadjii-msft commented on GitHub (Mar 1, 2022): We believe this was fixed in Terminal v1.13, in #11982. @matrdr would you mind confirming?
Author
Owner

@matrdr commented on GitHub (Mar 2, 2022):

We believe this was fixed in Terminal v1.13, in #11982. @matrdr would you mind confirming?

Seems fixed! Good job, guys!

@matrdr commented on GitHub (Mar 2, 2022): > We believe this was fixed in Terminal v1.13, in #11982. @matrdr would you mind confirming? Seems fixed! Good job, guys!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#16283