ANSI control sequence ESC M uses incorrect default background color (Windows Console Host) #5861

Open
opened 2026-01-31 00:23:41 +00:00 by claunia · 0 comments
Owner

Originally created by @12Me21 on GitHub (Jan 11, 2020).

Environment

Microsoft Windows [Version 10.0.18362.535]

Steps to reproduce

Screen background is set to any color other than 0:
image

From bash in WSL:

clear
echo -e "\e[H\e[1T"

image
The control sequence ESC [ 1 T scrolls down 1 line, and fills the new line with the background color
image

clear
echo -e "\e[H\eM"

image
The control sequence ESC M also scrolls down 1 line, but uses color 0 instead of the background color
image

Applications like less, man, and vim all use ESC M for scrolling, and scrolling upwards causes new lines to be filled with the wrong background color:
image

ESC [ L (insert lines) appears to have the same problem.

Additionally, this only happens when the current background color is set to the default. otherwise, ESC M acts correctly (try inserting \e[41m after the H in the command)

Expected behavior

Both control sequences should have the same behavior

Actual behavior

ESC M uses color 0 instead of the default color, when the background color is set to the default

Originally created by @12Me21 on GitHub (Jan 11, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Microsoft Windows [Version 10.0.18362.535] ``` # Steps to reproduce Screen background is set to any color other than 0: ![image](https://user-images.githubusercontent.com/4053256/72211525-e03e2b00-349a-11ea-8645-50e1770e13ca.png) From bash in WSL: ``` clear echo -e "\e[H\e[1T" ``` ![image](https://user-images.githubusercontent.com/4053256/72211510-af5df600-349a-11ea-8935-b99defee4ddc.png) The control sequence `ESC [ 1 T` scrolls down 1 line, and fills the new line with the background color ![image](https://user-images.githubusercontent.com/4053256/72211505-758cef80-349a-11ea-986a-b6e1dc3033e2.png) ``` clear echo -e "\e[H\eM" ``` ![image](https://user-images.githubusercontent.com/4053256/72211539-124f8d00-349b-11ea-9733-042c0eea65fb.png) The control sequence `ESC M` also scrolls down 1 line, but uses color 0 instead of the background color ![image](https://user-images.githubusercontent.com/4053256/72211542-23000300-349b-11ea-99d2-2bd037fddd01.png) Applications like `less`, `man`, and `vim` all use `ESC M` for scrolling, and scrolling upwards causes new lines to be filled with the wrong background color: ![image](https://user-images.githubusercontent.com/4053256/72211655-01078000-349d-11ea-8242-08888480eae7.png) `ESC [ L` (insert lines) appears to have the same problem. Additionally, this only happens when the current background color is set to the default. otherwise, ESC M acts correctly (try inserting `\e[41m` after the `H` in the command) # Expected behavior Both control sequences should have the same behavior # Actual behavior `ESC M` uses color 0 instead of the default color, when the background color is set to the default
claunia added the Resolution-Duplicate label 2026-01-31 00:23:41 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#5861