ansi terminal code reset breaks after scrolling #14394

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

Originally created by @akwebb1 on GitHub (Jul 4, 2021).

Windows Terminal version (or Windows build number)

wt 1.8.1521.0, wt 1.9.1523.0, windows 10.0.19043.0

Other Software

No response

Steps to reproduce

clear a powershell terminal screen with clear command.

run the following multiple times on the PowerShell command line until the terminal screen scrolls.

(0..255) | ForEach-Object {Write-Host "`e[48;5;$($_)m " -NoNewline};Write-Host "`e[0mX`n"

You can see the last output line does not properly reset the background and instead sets it to the background of the first character position on the line that the reset code is issued. There is an ansi reset terminal code sent just before the 'X' is displayed which works on all lines prior to the scrolling setting the background back to the default.

I get the same results with and without loading my PowerShell profile.

Screenshot 2021-07-04 130857

Expected Behavior

I expect that the output would be identical before and after the terminal window scrolls with the background being reset to the default.

Actual Behavior

After the terminal screen scrolls the background color after a reset code is sent is incorrect as shown above. If you clear the screen everything works as expected again until the terminal scrolls.

Originally created by @akwebb1 on GitHub (Jul 4, 2021). ### Windows Terminal version (or Windows build number) wt 1.8.1521.0, wt 1.9.1523.0, windows 10.0.19043.0 ### Other Software _No response_ ### Steps to reproduce clear a powershell terminal screen with clear command. run the following multiple times on the PowerShell command line until the terminal screen scrolls. ``` (0..255) | ForEach-Object {Write-Host "`e[48;5;$($_)m " -NoNewline};Write-Host "`e[0mX`n" ``` You can see the last output line does not properly reset the background and instead sets it to the background of the first character position on the line that the reset code is issued. There is an ansi reset terminal code sent just before the 'X' is displayed which works on all lines prior to the scrolling setting the background back to the default. I get the same results with and without loading my PowerShell profile. ![Screenshot 2021-07-04 130857](https://user-images.githubusercontent.com/2871794/124393683-9d44c880-dcc9-11eb-9a1b-ade2e9ee3117.png) ### Expected Behavior I expect that the output would be identical before and after the terminal window scrolls with the background being reset to the default. ### Actual Behavior After the terminal screen scrolls the background color after a reset code is sent is incorrect as shown above. If you clear the screen everything works as expected again until the terminal scrolls.
claunia added the Resolution-By-DesignNeeds-TriageNeeds-Tag-Fix labels 2026-01-31 04:09: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#14394