You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"`e[m " is a valid ANSI escape sequence that resets current formatting, short for "`e[0m "
The StringDecorated currently doesn't recognize it, and retains it as part of the data when plain-text conversion is requested.
# If you output the string directly to the terminal, you'll see that the trailing "." is NOT green anymore,# proving that "`e[m"` was effective in resetting the color.
([System.Management.Automation.Internal.StringDecorated]::new("`e[32mgreen`e[m.")).ToString('PlainText') |Format-Hex
Note:
Because terminals recognize "`e[m " correctly, the problem is usually hidden when the class is used behind the scenes in conjunction with $PSStyle.OutputRendering = 'PlainText', e.g. with $PSStyle.OutputRendering = 'PlainText'; wsl -e printf '\e[32mgreen\e[m.' | Out-Host.
Prerequisites
Steps to reproduce
"`e[m "is a valid ANSI escape sequence that resets current formatting, short for"`e[0m "The
StringDecoratedcurrently doesn't recognize it, and retains it as part of the data when plain-text conversion is requested.Note:
Because terminals recognize
"`e[m "correctly, the problem is usually hidden when the class is used behind the scenes in conjunction with$PSStyle.OutputRendering = 'PlainText', e.g. with$PSStyle.OutputRendering = 'PlainText'; wsl -e printf '\e[32mgreen\e[m.' | Out-Host.However, due to the - inappropriately closed - Streamed executable output prints Ansi Escaping in Write-* Commandlets #18771 - it currently does surface in
conhost.exewindows on Windows.Expected behavior
Actual behavior
Note the extraneous
�[mpart in theAsciicolumn, showing that`e[mwas unexpectedly retained.Error details
No response
Environment data
Visuals
No response