Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting doesn't handle the property with ANSI escape sequence string value properly, which leads to color leaking #17157

Closed
3 tasks done
thegraffix opened this issue Apr 16, 2022 · 2 comments · Fixed by #17262
Labels
Resolution-Fixed The issue is fixed. WG-Interactive-Console the console experience

Comments

@thegraffix
Copy link

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

N/A

Screenshot

Get-PSReadLineOption 1
Get-PSReadLineOption 2

Environment data

PS Version: 5.1.19041.1645
PS HostName: ConsoleHost
PSReadLine Version: 2.2.2
PSReadLine EditMode: Windows
OS: 10.0.19041.1 (WinBuild.160101.0800)
BufferWidth: 106
BufferHeight: 3000

Steps to reproduce

Happens on PS 5.1 console and Windows Terminal app (cannot reproduce with the ISE nor PowerShell 7.2.2)

To reproduce:

  1. Type Get-PSReadlineOption | Format-List *

To resolve:

  1. Type Get-PSReadLineOption (without | Format-List *) and color scheme is restored after the property CommandColor is listed on-screen. See bottom screenshot for a better explanation of this.

Expected behavior

Color scheme should remain constant

Actual behavior

  • Console color scheme now appears like the ListPredictionSelectedColor color scheme
  • Missing property values (see screenshot)
  • Clearing the screen/changing console size doesn't resolve the issue.
@ghost ghost added the Needs-Triage 🔍 label Apr 16, 2022
@daxian-dbw
Copy link
Member

daxian-dbw commented Apr 18, 2022

This is an issue with the PowerShell formatting. When using Format-List *, the formatting view registered by the PSReadLine module won't be used. Instead, PowerShell formatting will dump every property of the object and display them in a list view.

The problem is that PowerShell formatting doesn't handle ANSI escape codes properly. The color properties are all holding ANSI sequences for color, which should not be simply written to console as regular strings. And doing so will lead to color leaking, which is what is observed in your screenshot. I will transfer this issue to PowerShell repo.

@daxian-dbw daxian-dbw transferred this issue from PowerShell/PSReadLine Apr 18, 2022
@daxian-dbw daxian-dbw changed the title Unexpected screen colors/behavior/missing property values when doing: Get-PSReadLineOption | Format-List * Formatting doesn't handle the property with ANSI escape sequence string value properly, which leads to color leaking Apr 18, 2022
@SeeminglyScience SeeminglyScience added WG-Interactive-Console the console experience Needs-Triage The issue is new and needs to be triaged by a work group. Needs-Triage 🔍 and removed Needs-Triage 🔍 labels Apr 18, 2022
@ghost ghost added the In-PR Indicates that a PR is out for the issue label May 4, 2022
@ghost ghost added Resolution-Fixed The issue is fixed. and removed Needs-Triage The issue is new and needs to be triaged by a work group. In-PR Indicates that a PR is out for the issue labels May 10, 2022
@ghost
Copy link

ghost commented May 23, 2022

🎉This issue was addressed in #17262, which has now been successfully released as v7.3.0-preview.4.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution-Fixed The issue is fixed. WG-Interactive-Console the console experience
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants