-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
$PsStyle.OutputFormatting = PlainText is ineffective when host is not 'ConsoleHost' #16643
Comments
I do not know. In Windows Console Host and in VSCode all are working as expected. If I set to 'PlainText' the coloring disappeared in entire console screen. |
@237dmitry |
OK, I understand now, yes that looks right in a pwsh pane. My issue is the integrated one |
VSCode integrated console and PowerShell notebook use different hosts, which haven't been updated to work with |
Quote the discussion between @jhoneill and me from #16635 (comment)
Unfortunately, yes. In PowerShell itself, the work that strips off the ANSI code is done in ConsoleHost, and that makes it necessary for other host to do something similar. But you made me start to think, maybe that's not the right design, maybe that should be done in formatting before sending the payload to host ... there could be other applications that hosts PowerShell out there in the wild, and requiring extra work to their host after upgrading to PS 7.2 is not a pleasant ask for sure. We may want to rethink about where to strip off the ANSI code. Does this work have to be done in host implementation? If not, it's better to do it in PowerShell formatting, so various hosts out in the wild don't need to change for |
There seem to be other problems relating to different hosts, which suggest - per @daxian-dbw above - shifting this out of the host is a good idea. The screen shot below is using a .NET interactive notebook. On the bottom row, blue is used to highlight some types of action and (2) shows the codes for "foreground blue" and "reset" have reduced padding before the next column. Neither (1) nor (2) occurs in the default host, but making people who create other hosts bring over multiple pieces of functionality is not ideal. |
It seems to me that if a host could declare or be constructed what formats it supports (plaintext only, console emits, ANSI support), then Powershell should send that output to the host and do that work, and the host can either pass it thorugh or do with it what it wants. |
@daxian-dbw FWIW, I'm facing this issue using SAPIEN PowerShell Studio. |
Looking for something else this is fixed with the newest PowerShell integrated console in VSCode, but the problem remains in .NET Interactive. |
@jhoneill PowerShell integrated console started to wrap a console host instance internally. The .NET Interactive cannot wrap console host within it, because it's not facing a terminal, but the .NET Interactive stdin/stdout channel. |
@daxian-dbw so something that works that way can't get clean output then ? |
The PowerShell sub-kernel host needs to be updated to strip off the VT sequences properly as controlled by |
But it will be done at some point ? |
Should that be a switch passed in via pwsh, to control stripping of characters when pwsh called directly |
The Working Group has reviewed this issue and agrees it should be filed with .Net Interactive. For discussions regarding the design of PSStyle and it implementation, please open a separate issue. |
This issue has been marked as external and has not had any activity for 1 day. It has been be closed for housekeeping purposes. |
@theJasonHelmick What troubles me here is: Is .NET interactive the only host with any meaningful user-base which needs to take on the extra work to integrate with PowerShell, or are there a few, or potentially many ? For small numbers filing an issue with them is the right course. For large numbers the solution should be coming from the PowerShell team. I don't know of any others so I'm happy with this marked as external and closed, at least for now. We may need to re-visit but no sense it getting overly worried because it is more likely we won't. |
Prerequisites
Steps to reproduce
Setting $PSStyle.OutputRendering = "PlainText" removes colour. However it only seems to do so if the
$host.name
isConsoleHost
so using a .Net Interactive notebook (which doesn't load the profile as a way to set psstyle preferences) or the the PowerShell Integrated console in VS Code. (".NET Interactive Host" and " Visual Studio Code Host" respectively)Expected behavior
Setting $PSStyle.OutputRendering = "PlainText" removes colour
Actual behavior
Setting $PSStyle.OutputRendering = "PlainText" does not removes colour when the host is not "Consolehost" see visuals
Error details
No message
Environment data
Visuals
Below both show labels in green despite plain text being selected.
.Net Interactive notebook
PowerShell Integrated Console in VS Code.
In the console host (Windows terminal, legacy console, and pwsh in VS Code outside the integrated vs code console). plain text removes the green colouring.
The text was updated successfully, but these errors were encountered: