@@ -742,7 +742,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_System_Management_Autom
742742 CustomControl . Create ( outOfBand : true )
743743 . StartEntry ( )
744744 . AddScriptBlockExpressionBinding ( @"
745- if (@('NativeCommandErrorMessage'. 'NativeCommandError') -notcontains $_.FullyQualifiedErrorId -and @('CategoryView','ConciseView') -notcontains $ErrorView)
745+ if (@('NativeCommandErrorMessage', 'NativeCommandError') -notcontains $_.FullyQualifiedErrorId -and @('CategoryView','ConciseView') -notcontains $ErrorView)
746746 {
747747 $myinv = $_.InvocationInfo
748748 if ($myinv -and $myinv.MyCommand)
@@ -795,6 +795,7 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_System_Management_Autom
795795 . AddScriptBlockExpressionBinding ( @"
796796
797797 function Get-ConciseViewPositionMessage {
798+ Set-StrictMode -Off
798799
799800 $resetColor = ''
800801 if ($Host.UI.SupportsVirtualTerminal) {
@@ -880,7 +881,7 @@ function Get-ConciseViewPositionMessage {
880881
881882 if ($myinv -and $myinv.ScriptName -or $_.CategoryInfo.Category -eq 'ParserError') {
882883 if ($myinv.ScriptName) {
883- $posmsg = ""error in ${resetcolor} $($myinv.ScriptName)${newline}""
884+ $posmsg = ""${resetcolor}$($myinv.ScriptName)${newline}""
884885 }
885886 else {
886887 $posmsg = ""${newline}""
@@ -901,8 +902,12 @@ function Get-ConciseViewPositionMessage {
901902 $line = $myinv.Line
902903 $highlightLine = $myinv.PositionMessage.Split('+').Count - 1
903904 $offsetLength = $myinv.PositionMessage.split('+')[$highlightLine].Trim().Length
904- $line = $line.Insert($myinv.OffsetInLine - 1 + $offsetLength, $resetColor)
905- $line = $line.Insert($myinv.OffsetInLine - 1, $errorColor)
905+
906+ # don't color the whole line red
907+ if ($offsetLength -lt $line.Length - 1) {
908+ $line = $line.Insert($myinv.OffsetInLine - 1 + $offsetLength, $resetColor).Insert($myinv.OffsetInLine - 1, $accentColor)
909+ }
910+
906911 $posmsg += ""${accentColor}${lineWhitespace}$($myinv.ScriptLineNumber) ${verticalBar} ${resetcolor}${line}`n""
907912 $offsetWhitespace = ' ' * ($myinv.OffsetInLine - 1)
908913 $prefix = ""${accentColor}${headerWhitespace} ${verticalBar} ${errorColor}""
@@ -965,7 +970,7 @@ function Get-ConciseViewPositionMessage {
965970 elseif ($_.CategoryInfo.Category) {
966971 $reason = $_.CategoryInfo.Category
967972 }
968- elseif ($_CategoryInfo .Reason) {
973+ elseif ($_.CategoryInfo .Reason) {
969974 $reason = $_.CategoryInfo.Reason
970975 }
971976
0 commit comments