From 65b353d9cf90c3581e97d8be6620cd9627cf8ac8 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Tue, 15 Nov 2022 17:54:23 -0800 Subject: [PATCH] The command prefix should also be in the error color for `NormalView` (#18555) --- .../PowerShellCore_format_ps1xml.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs b/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs index 80aef760ac..7b184cd9a4 100644 --- a/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs +++ b/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs @@ -1000,8 +1000,12 @@ namespace System.Management.Automation.Runspaces if (@('NativeCommandErrorMessage','NativeCommandError') -notcontains $_.FullyQualifiedErrorId -and @('CategoryView','ConciseView','DetailedView') -notcontains $ErrorView) { $myinv = $_.InvocationInfo - if ($myinv -and $myinv.MyCommand) - { + $errorColor = '' + if ($Host.UI.SupportsVirtualTerminal) { + $errorColor = $PSStyle.Formatting.Error + } + + $commandPrefix = if ($myinv -and $myinv.MyCommand) { switch -regex ( $myinv.MyCommand.CommandType ) { ([System.Management.Automation.CommandTypes]::ExternalScript) @@ -1046,6 +1050,11 @@ namespace System.Management.Automation.Runspaces $myinv.InvocationName + ' : ' } } + + if ($commandPrefix) + { + $errorColor + $commandPrefix + } ") .AddScriptBlockExpressionBinding(@" Set-StrictMode -Off