Clear to end of line doesn't work correctly with reverse mode #18555

Closed
opened 2026-01-31 06:17:33 +00:00 by claunia · 8 comments
Owner

Originally created by @RadAd on GitHub (Sep 27, 2022).

Windows Terminal version

1.15.2524.0

Windows build number

10.0.19044.2006

Other Software

No response

Steps to reproduce

Clear to end of line \x1b[0K not behaving correctly in combination with reverse mode \x1b[7m.

#include <cstdio>

int main()
{
    printf("\x1b[34;43mLine 1\x1b[0K\n");
    printf("\x1b[7mLine 2\x1b[0K\n");
    printf("\x1b[0m\x1b[0K\n");
}

Expected Behavior

Under the old console I get this:
image

Actual Behavior

In the new terminal I get this:
image

Originally created by @RadAd on GitHub (Sep 27, 2022). ### Windows Terminal version 1.15.2524.0 ### Windows build number 10.0.19044.2006 ### Other Software _No response_ ### Steps to reproduce Clear to end of line `\x1b[0K` not behaving correctly in combination with reverse mode `\x1b[7m`. ``` #include <cstdio> int main() { printf("\x1b[34;43mLine 1\x1b[0K\n"); printf("\x1b[7mLine 2\x1b[0K\n"); printf("\x1b[0m\x1b[0K\n"); } ``` ### Expected Behavior Under the old console I get this: ![image](https://user-images.githubusercontent.com/2518689/192430291-e4d28796-a17f-4b90-a61f-db4059b7b5b4.png) ### Actual Behavior In the new terminal I get this: ![image](https://user-images.githubusercontent.com/2518689/192430364-abc913ab-1d4e-42e1-9419-f9ac3c14c0ec.png)
claunia added the Resolution-By-DesignNeeds-TriageIssue-Bug labels 2026-01-31 06:17:33 +00:00
Author
Owner

@237dmitry commented on GitHub (Sep 27, 2022):

Try \x1b[k instead of \x1b[0K

Screenshot 2022-09-27 100021

@237dmitry commented on GitHub (Sep 27, 2022): Try `\x1b[k` instead of `\x1b[0K` ![Screenshot 2022-09-27 100021](https://user-images.githubusercontent.com/78153320/192455874-24b05e63-abe1-4130-9a0b-88ae92b63a78.png)
Author
Owner

@RadAd commented on GitHub (Sep 27, 2022):

Your test should have been:

"`e[34;43mLine 1`e[K`n`e[7mLine 2`e[K`n`e[0m`n"`

to match my test.
Also, your screenshot doesn't look correct. It should be cleared out to the end of the line. I think it's because you used the lowercase K. I believe these CSI sequences are case-sensitive.
In any case, your suggestion didn't change my results.

@RadAd commented on GitHub (Sep 27, 2022): Your test should have been: ``` "`e[34;43mLine 1`e[K`n`e[7mLine 2`e[K`n`e[0m`n"` ``` to match my test. Also, your screenshot doesn't look correct. It should be cleared out to the end of the line. I think it's because you used the lowercase K. I believe these CSI sequences are case-sensitive. In any case, your suggestion didn't change my results.
Author
Owner

@j4james commented on GitHub (Sep 27, 2022):

@RadAd The behavior you were seeing in the old console was a bug that has since been fixed. The erase operations (like EL, ED, and ECH) are meant to fill the affected area with empty rendition attributes (i.e. thing like underline and reverse video aren't meant to be applied).

@j4james commented on GitHub (Sep 27, 2022): @RadAd The behavior you were seeing in the old console was a bug that has since been fixed. The erase operations (like `EL`, `ED`, and `ECH`) are meant to fill the affected area with empty rendition attributes (i.e. thing like underline and reverse video aren't meant to be applied).
Author
Owner

@DHowett commented on GitHub (Sep 27, 2022):

@j4james is correct. The original behavior was a bug, which has been fixed both in newer versions of Windows and in Windows Terminal. Thanks for the report!

@DHowett commented on GitHub (Sep 27, 2022): @j4james is correct. The original behavior was a bug, which has been fixed both in newer versions of Windows and in Windows Terminal. Thanks for the report!
Author
Owner

@RadAd commented on GitHub (Sep 27, 2022):

Is the fix going to be applied to Windows 10?

@RadAd commented on GitHub (Sep 27, 2022): Is the fix going to be applied to Windows 10?
Author
Owner

@DHowett commented on GitHub (Sep 27, 2022):

Unlikely. For Windows 10, the fix will be distributed via Windows Terminal.

@DHowett commented on GitHub (Sep 27, 2022): Unlikely. For Windows 10, the fix will be distributed via Windows Terminal.
Author
Owner

@RadAd commented on GitHub (Sep 27, 2022):

Does updating Windows Terminal fix the issue in the old console?

@RadAd commented on GitHub (Sep 27, 2022): Does updating Windows Terminal fix the issue in the old console?
Author
Owner

@DHowett commented on GitHub (Sep 27, 2022):

Unfortunately, it won't. ☹️

@DHowett commented on GitHub (Sep 27, 2022): Unfortunately, it won't. ☹️
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18555