Skip to content

$PSStyle cause issues in the PowerShell Console #14435

Closed

Description

@rjmholt

Simple repro

Write-Verbose -verbose "verbose";Write-Output "out"

expected output

image

Actual results

image

VSCode reproduce

$PSVersionTable
$PSStyle.Formatting.Warning = $PSStyle.Background.Magenta + $PSStyle.Foreground.Yellow + $PSStyle.Bold + $PSStyle.Italic
Write-Warning "Colours!"

Expected behavior

image

and something like this:

image

Actual behavior

Notice the yellow:

image

image

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.0-preview.2
PSEdition                      Core
GitCommitId                    7.2.0-preview.2
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}       
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. TylerLeonhardt commented on Dec 16, 2020

    @TylerLeonhardt
    Member

    Also worth looking at .NET Interactive - another pshost.

  2. SeeminglyScience commented on Dec 16, 2020

    @SeeminglyScience
    Contributor

    Hmm I can't repro the color leaking. (Edit: Didn't have the experimental feature enabled) As for the style not taking effect, yeah every custom host will need to implement this themselves.

    It would be nice if ConsoleHost was redesigned somewhat to be inheritable. That doesn't really help PSES and such right now unless it's polyfilled but it would save a lot of headache in the future.

  3. rjmholt commented on Dec 16, 2020

    @rjmholt
    CollaboratorAuthor

    As for the style not taking effect, yeah every custom host will need to implement this themselves.

    I think we need a bit more platform-oriented thinking here

  4. SeeminglyScience commented on Dec 16, 2020

    @SeeminglyScience
    Contributor

    I think we need a bit more platform-oriented thinking here

    Yeah I'm with ya there. I'm not really sure how though, those streams don't make it to anything like the formatter where this could be processed in a host agnostic way. In most cases MshCommandRuntime.WriteVerbose goes directly to PSHostUserInterface.WriteVerboseLine.

    Another challenge is that escape sequences do not do much to describe what a GUI host should do. I didn't see the PR at the time, but if I did I would have recommended removing the customizations of the other streams until this was fleshed out a little bit more.

  5. changed the title [-]$PSStyle cause issues in the VSCode PowerShell extension Integrated Console[/-] [+]$PSStyle cause issues in the PowerShell Console[/+] on Feb 2, 2021
  6. SteveL-MSFT commented on Aug 4, 2021

    @SteveL-MSFT
    Member

    This seems to be working fine with 7.2-preview.8

  7. SteveL-MSFT commented on Aug 4, 2021

    @SteveL-MSFT
    Member

    I think this is a dupe of #14506 which was already fixed

  8. rjmholt commented on Aug 4, 2021

    @rjmholt
    CollaboratorAuthor
    $PSStyle.Formatting.Warning = $PSStyle.Background.Magenta + $PSStyle.Foreground.Yellow + $PSStyle.Bold + $PSStyle.Italic
    Write-Warning "Colours!"
    

    This doesn't produce the magenta background, but otherwise things seem to be working.

    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions