RawUI & PrivateData: Console Colors are broken? #559

Closed
opened 2026-01-30 21:55:15 +00:00 by claunia · 5 comments
Owner

Originally created by @JontuKontar on GitHub (Feb 13, 2019).

When using (Get-Host).PrivateData or (Get-Host).UI.RawUI to set Console Colors, they only exist when the console is opened.

Typed text is not bound to them nor do the properties of PrivateData or RawUI indicate that they are properly set. (Clear-Host, effectively removes all changes from the Console.)

Enabling "Use Legacy Console" restores expected function.

Not sure if there is something else I should be doing to make the color changes stick with the "Modern Console" or if this is a legitimate bug in the way console colors are applied to the Console.

Originally created by @JontuKontar on GitHub (Feb 13, 2019). When using `(Get-Host).PrivateData` or `(Get-Host).UI.RawUI` to set Console Colors, they only exist when the console is opened. Typed text is not bound to them nor do the properties of `PrivateData` or `RawUI` indicate that they are properly set. (`Clear-Host`, effectively removes all changes from the Console.) Enabling "Use Legacy Console" restores expected function. Not sure if there is something else I should be doing to make the color changes stick with the "Modern Console" or if this is a legitimate bug in the way console colors are applied to the Console.
Author
Owner

@zadjii-msft commented on GitHub (Feb 13, 2019):

If this is a regression between the v1 (legacy) and v2 consoles, we're happy to take a look, but we'll need a minimal repro that we can use to debug this.


From: Oisin Grehan notifications@github.com
Sent: Wednesday, February 13, 2019 7:15:42 AM
To: Microsoft/console
Cc: Subscribed
Subject: Re: [Microsoft/console] RawUI & PrivateData: Console Colors are broken? (#372)

This issue belongs on github.com/powershell/powershell

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoft%2Fconsole%2Fissues%2F372%23issuecomment-463236848&data=02%7C01%7CMike.Griese%40microsoft.com%7Cf6ec458a32bf4cb4d12008d691c61f0a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636856677440645481&sdata=FoAnAsA%2B8mVkQ0DBCTDVqHkguUxfR9CjM9RygvpwtJ8%3D&reserved=0, or mute the threadhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FARgZ1oFPTeW1Zuc3Jzjv50imrv-Tfh0wks5vNCwegaJpZM4a5l_C&data=02%7C01%7CMike.Griese%40microsoft.com%7Cf6ec458a32bf4cb4d12008d691c61f0a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636856677440655490&sdata=iojg67Hl%2B0UdsiCnz8xJ2HTjV2cK8%2B9cWqm06FFrMlw%3D&reserved=0.

@zadjii-msft commented on GitHub (Feb 13, 2019): If this is a regression between the v1 (legacy) and v2 consoles, we're happy to take a look, but we'll need a minimal repro that we can use to debug this. ________________________________ From: Oisin Grehan <notifications@github.com> Sent: Wednesday, February 13, 2019 7:15:42 AM To: Microsoft/console Cc: Subscribed Subject: Re: [Microsoft/console] RawUI & PrivateData: Console Colors are broken? (#372) This issue belongs on github.com/powershell/powershell — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoft%2Fconsole%2Fissues%2F372%23issuecomment-463236848&data=02%7C01%7CMike.Griese%40microsoft.com%7Cf6ec458a32bf4cb4d12008d691c61f0a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636856677440645481&sdata=FoAnAsA%2B8mVkQ0DBCTDVqHkguUxfR9CjM9RygvpwtJ8%3D&reserved=0>, or mute the thread<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FARgZ1oFPTeW1Zuc3Jzjv50imrv-Tfh0wks5vNCwegaJpZM4a5l_C&data=02%7C01%7CMike.Griese%40microsoft.com%7Cf6ec458a32bf4cb4d12008d691c61f0a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636856677440655490&sdata=iojg67Hl%2B0UdsiCnz8xJ2HTjV2cK8%2B9cWqm06FFrMlw%3D&reserved=0>.
Author
Owner

@lawlz commented on GitHub (Mar 30, 2019):

Hey All!

I am having the same issue and I believe it is related to the psreadline v2, which you probably already know, since there are many issues around console coloring, #818, #774, #276 . Here is a reproduction of what I am seeing:

image

See how the foregroundcolor reverts to an initial or default background color, and potentially because they are writing CSI 0 m and not saving or persisting this new console color setting. Comment found here from the main maintainer.

After downloading the latest module from the above repo, it seems to be working, but the versioning is weird. It appears the psreadline module in the repo is still 1.0 and the version that is shipped with windows is installing the 2.0, which appears to be beta... Also, any reference to the 2.0 Beta still seems to tie back to the repo above which has the 1.0 versioning... Here is a reference to 2.0, but the only activity from SteveL, externally facing that is, shows a forked repo of the above PSReadline.

Here it is working from the package downloaded from that repo:

errorRepro

Long story short, I believe this to be a duplicate issue and fixed in a 'new' version of PSReadline, unless the goal is to move away from the 1.0 and go to 2.0. If that is the case, the latest build for 2.0, that I could find, was last updated last September and still a beta and still has this issue. I am not sure, but wanted to update this issue and hopefully get some insider insight on what the direction forward is on this module and maybe why MS would ship a beta version of a module when, on this machine, I don't have developer mode on or anything. Thank you.

@lawlz commented on GitHub (Mar 30, 2019): Hey All! I am having the same issue and I believe it is related to the psreadline v2, which you probably already know, since there are many issues around console coloring, [#818](https://github.com/lzybkr/PSReadLine/issues/818), [#774](https://github.com/lzybkr/PSReadLine/issues/774), #276 . Here is a reproduction of what I am seeing: ![image](https://user-images.githubusercontent.com/6010549/55277322-d01edb80-52cc-11e9-88ae-9749beca776b.png) See how the foregroundcolor reverts to an initial or default background color, and potentially because they are writing `CSI 0 m` and not saving or persisting this new console color setting. Comment found here from the [main maintainer](https://github.com/Microsoft/console/issues/276#issuecomment-432106661). After downloading the latest module from the above repo, it seems to be working, but the versioning is weird. It appears the psreadline module in the repo is still 1.0 and the version that is shipped with windows is installing the 2.0, which appears to be beta... Also, any reference to the 2.0 Beta still seems to tie back to the repo above which has the 1.0 versioning... Here is a [reference to 2.0](https://github.com/lzybkr/PSReadLine/issues/854#issuecomment-477851836), but the only activity from SteveL, externally facing that is, shows a forked repo of the above PSReadline. Here it is working from the package downloaded from that repo: ![errorRepro](https://user-images.githubusercontent.com/6010549/55278464-a66cb100-52da-11e9-95fb-39c55107d4ef.PNG) Long story short, I believe this to be a duplicate issue and fixed in a 'new' version of PSReadline, unless the goal is to move away from the 1.0 and go to 2.0. If that is the case, the latest build for 2.0, that I could find, was last updated [last September and still a beta](https://www.powershellgallery.com/packages/PSReadLine/2.0.0-beta3) and still has this issue. I am not sure, but wanted to update this issue and hopefully get some insider insight on what the direction forward is on this module and maybe why MS would ship a beta version of a module when, on this machine, I don't have developer mode on or anything. Thank you.
Author
Owner

@DHowett-MSFT commented on GitHub (May 18, 2019):

maybe why MS would ship a beta version of a module

If I had to guess, it's because PSReadline 2.0 (even in beta) is so much better than 1.4 that it was worth it in their risk assessment.

Since it looks like this issue was originally caused by PSReadline saving and restoring colors, I'm going to mark this one for garbage collection. If it isn't because PSReadline was saving and restoring colors, please feel free to reopen it.

(A quick check: Remove-Module PSReadline, then do your color test. If they still don't stay, it could be our fault.)

@DHowett-MSFT commented on GitHub (May 18, 2019): > maybe why MS would ship a beta version of a module If I had to guess, it's because PSReadline 2.0 (even in beta) is so much better than 1.4 that it was worth it in their risk assessment. Since it looks like this issue was originally caused by PSReadline saving and restoring colors, I'm going to mark this one for garbage collection. If it _isn't_ because PSReadline was saving and restoring colors, please feel free to reopen it. (A quick check: `Remove-Module PSReadline`, then do your color test. If they still don't stay, it could be our fault.)
Author
Owner

@ghost commented on GitHub (May 22, 2019):

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost commented on GitHub (May 22, 2019): This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
Author
Owner

@lawlz commented on GitHub (May 26, 2019):

Thank you so much for the reply and information. Yes it works fine once you remove-module psreadline, but of course you lose all that PSReadLine goodness.

As an aside, I pulled down the 2.0.0-Beta4 version that was released to the Gallery 19 days ago and it appears to have the required patch to fix this issue!

Thanks again for your help Dustin!

@lawlz commented on GitHub (May 26, 2019): Thank you so much for the reply and information. Yes it works fine once you `remove-module psreadline`, but of course you lose all that PSReadLine goodness. As an aside, I pulled down the 2.0.0-Beta4 version that was released to the [Gallery 19 days ago](https://www.powershellgallery.com/packages/PSReadLine/2.0.0-beta4) and it appears to have the required patch to fix this issue! Thanks again for your help Dustin!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#559