Skip to content

$ErrorView = 'NormalView' leaves the console in Error color after rendering an ErrorRecord #17885

Closed

Description

Prerequisites

Steps to reproduce

Repro steps:

  1. Open the latest PowerShell preview.7, and make sure using the default prompt
  2. Run $ErrorView = 'NormalView'
  3. Run Write-Error 'error'

This is a bug introduced by #17705.
The Cosnole.ForegroundColor and Console.BackgroundColor were changed but never set back after writing out the message.

if ($ErrorView -ne 'ConciseView' -and $null -ne $host.PrivateData) {
if ($null -ne $host.PrivateData.ErrorForegroundColor) {
[Console]::ForegroundColor = $host.PrivateData.ErrorForegroundColor
}
if ($null -ne $host.PrivateData.ErrorBackgroundColor) {
[Console]::BackgroundColor = $host.PrivateData.ErrorBackgroundColor
}
}

Expected behavior

The prompt after executing `Write-Error 'error'` doesn't have the color changed

Actual behavior

The prompt gets changed to the error color

Error details

N/A

Environment data

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

Visuals

image

Activity

  1. added
    Needs-Triage
    on Aug 12, 2022
  2. nightroman commented on Aug 13, 2022

    @nightroman

    I experience this regression in the just released PowerShell 7.2.6.
    PowerShell 7.2.5 works as expected.

  3. added
    WG-Engine
    on Aug 13, 2022
  4. ghost added
    In-PR
    on Aug 15, 2022
  5. ghost removed
    In-PR
    on Aug 31, 2022
  6. ghost added
    Resolution-Fixed
    on Aug 31, 2022
  7. ghost removed
    Needs-Triage
    on Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Resolution-FixedWG-Engine

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions