@@ -926,7 +926,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_System_Management_Autom
926
926
CustomControl . Create ( outOfBand : true )
927
927
. StartEntry ( )
928
928
. AddScriptBlockExpressionBinding ( @"
929
- if (@('NativeCommandErrorMessage'. 'NativeCommandError') -notcontains $_.FullyQualifiedErrorId -and @('CategoryView','ConciseView') -notcontains $ErrorView)
929
+ if (@('NativeCommandErrorMessage', 'NativeCommandError') -notcontains $_.FullyQualifiedErrorId -and @('CategoryView','ConciseView') -notcontains $ErrorView)
930
930
{
931
931
$myinv = $_.InvocationInfo
932
932
if ($myinv -and $myinv.MyCommand)
@@ -979,6 +979,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_System_Management_Autom
979
979
. AddScriptBlockExpressionBinding ( @"
980
980
981
981
function Get-ConciseViewPositionMessage {
982
+ Set-StrictMode -Off
982
983
983
984
$resetColor = ''
984
985
if ($Host.UI.SupportsVirtualTerminal) {
@@ -1064,7 +1065,7 @@ function Get-ConciseViewPositionMessage {
1064
1065
1065
1066
if ($myinv -and $myinv.ScriptName -or $_.CategoryInfo.Category -eq 'ParserError') {
1066
1067
if ($myinv.ScriptName) {
1067
- $posmsg = ""error in ${resetcolor} $($myinv.ScriptName)${newline}""
1068
+ $posmsg = ""${resetcolor}$($myinv.ScriptName)${newline}""
1068
1069
}
1069
1070
else {
1070
1071
$posmsg = ""${newline}""
@@ -1085,8 +1086,12 @@ function Get-ConciseViewPositionMessage {
1085
1086
$line = $myinv.Line
1086
1087
$highlightLine = $myinv.PositionMessage.Split('+').Count - 1
1087
1088
$offsetLength = $myinv.PositionMessage.split('+')[$highlightLine].Trim().Length
1088
- $line = $line.Insert($myinv.OffsetInLine - 1 + $offsetLength, $resetColor)
1089
- $line = $line.Insert($myinv.OffsetInLine - 1, $errorColor)
1089
+
1090
+ # don't color the whole line red
1091
+ if ($offsetLength -lt $line.Length - 1) {
1092
+ $line = $line.Insert($myinv.OffsetInLine - 1 + $offsetLength, $resetColor).Insert($myinv.OffsetInLine - 1, $accentColor)
1093
+ }
1094
+
1090
1095
$posmsg += ""${accentColor}${lineWhitespace}$($myinv.ScriptLineNumber) ${verticalBar} ${resetcolor}${line}`n""
1091
1096
$offsetWhitespace = ' ' * ($myinv.OffsetInLine - 1)
1092
1097
$prefix = ""${accentColor}${headerWhitespace} ${verticalBar} ${errorColor}""
@@ -1149,7 +1154,7 @@ function Get-ConciseViewPositionMessage {
1149
1154
elseif ($_.CategoryInfo.Category) {
1150
1155
$reason = $_.CategoryInfo.Category
1151
1156
}
1152
- elseif ($_CategoryInfo .Reason) {
1157
+ elseif ($_.CategoryInfo .Reason) {
1153
1158
$reason = $_.CategoryInfo.Reason
1154
1159
}
1155
1160
0 commit comments