Underline ANSI escape sequence does not work with space before reset sequence #9690

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

Originally created by @patriksvensson on GitHub (Jul 20, 2020).

I've noticed that using ANSI escape sequence ESC[4mFOO ESC[0m does not underline the text as expected.
If I remove the space before the reset code ESC[0m, it works as expected.

This works as expected in cmd.exe/powershell.exe (which I assume both uses conhost), conemu and cmder.

Environment

Windows build number: Microsoft Windows NT 10.0.19041.0
Windows Terminal version (if applicable): 1.0.1811.0

Steps to reproduce

  1. Open PowerShell console in Windows Terminal
  2. Run Write-Host "$([char]27)[1mBold$([char]27)[0m $([char]27)[4mUnderline$([char]27)[0m Normal"
    This underlines the text "Underline" as expected.
  3. Run Write-Host "$([char]27)[1mBold $([char]27)[0m$([char]27)[4mUnderline$([char]27)[0m Normal"
    This fails with underlining the text.

They say that a picture is worth a thousand words, so here's a screenshot as well of the repro.

image

Expected behavior

In the third step in the repro, I would expect the text Underline to be underlined.

Actual behavior

The text Underline is not underlined.

Originally created by @patriksvensson on GitHub (Jul 20, 2020). I've noticed that using ANSI escape sequence `ESC[4mFOO ESC[0m` does not underline the text as expected. If I remove the space before the reset code `ESC[0m`, it works as expected. This works as expected in `cmd.exe`/`powershell.exe` (which I assume both uses conhost), `conemu` and `cmder`. # Environment ```none Windows build number: Microsoft Windows NT 10.0.19041.0 Windows Terminal version (if applicable): 1.0.1811.0 ``` # Steps to reproduce 1. Open PowerShell console in Windows Terminal 2. Run `Write-Host "$([char]27)[1mBold$([char]27)[0m $([char]27)[4mUnderline$([char]27)[0m Normal"` *This underlines the text "Underline" as expected.* 3. Run `Write-Host "$([char]27)[1mBold $([char]27)[0m$([char]27)[4mUnderline$([char]27)[0m Normal"` *This fails with underlining the text.* They say that a picture is worth a thousand words, so here's a screenshot as well of the repro. ![image](https://user-images.githubusercontent.com/357872/87888639-45686f80-ca2e-11ea-93e8-9190ca76ec54.png) # Expected behavior In the third step in the repro, I would expect the text `Underline` to be underlined. # Actual behavior The text `Underline` is not underlined.
claunia added the Resolution-Duplicate label 2026-01-31 02:01:01 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#9690