Ensure error message resets the color#17904
Ensure error message resets the color#17904SteveL-MSFT wants to merge 2 commits intoPowerShell:masterfrom
Conversation
|
Open PRs should not be assigned to milestone, so they are not assigned to the wrong milestone after they are merged. For backport consideration, use a |
...stem.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs
Outdated
Show resolved
Hide resolved
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
|
I cherry-picked the changes to 7.2.6 branch trying to make sure the changes work on 7.2.next. It turns out this works fine on Windows but not so well on Linux: As shown in the GIF, the first prompt after I also tried the 7.3 private build, and it works fine on both Windows and Linux. There are big changes in .NET 7 in the Console area, so I guess that was fixed in .NET 7. However, we need it to work well on 7.2.6 (.NET 6) if we want to backport this change. |
|
Given what I found above, I think we should not rely on setting One caveat is that |
|
Actually, I have question: why do we have to use colors defined in After introducing
So, it feels to me we should just use |
|
@daxian-dbw the feedback was that it broke existing users of NormalView who set the color in their $profile. Perhaps we should have a WG review. There may have been some other changes that would need to be cherry-picked to 7.2 to make it work completely. |
It's already broken for other formatting color settings defined in |
|
Waiting on the WG-Interactive-Console group to decide what to do with PrivateData. |
|
The Interactive WG discussed |
|
This PR is superseded by #17987 |

PR Summary
Prior to this change, after writing the error message if your prompt doesn't set any colors, the error color (default red) would continue to write to output.
Looked at changing it so that the color resets at writeline() time but that didn't work correctly across multiple lines as they should all be red, but because lines expect color to be retained, they would show incorrectly.
Ultimately, decided that the error message itself should reset the color (which also means that all output needs to reset at the end rather than expecting PS or ConsoleHost to fix it).
Manually tested with ConciseView and NormalView using:
Where the error should be in red even if multiple lines, but
helloshould be default foreground/background color.PR Context
Fix #17885
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).