mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Update ConciseView to remove unnecessary text and not color entire line in red (#10724)
This commit is contained in:
1 parent
d2c04f3eef
commit
bce5b20d2d
1 file changed
+10
-5
+10
-5
@@ -742,7 +742,7 @@ namespace System.Management.Automation.Runspaces
|
||||
CustomControl.Create(outOfBand: true)
|
||||
.StartEntry()
|
||||
.AddScriptBlockExpressionBinding(@"
|
||||
if (@('NativeCommandErrorMessage'.'NativeCommandError') -notcontains $_.FullyQualifiedErrorId -and @('CategoryView','ConciseView') -notcontains $ErrorView)
|
||||
if (@('NativeCommandErrorMessage','NativeCommandError') -notcontains $_.FullyQualifiedErrorId -and @('CategoryView','ConciseView') -notcontains $ErrorView)
|
||||
{
|
||||
$myinv = $_.InvocationInfo
|
||||
if ($myinv -and $myinv.MyCommand)
|
||||
@@ -795,6 +795,7 @@ namespace System.Management.Automation.Runspaces
|
||||
.AddScriptBlockExpressionBinding(@"
|
||||
|
||||
function Get-ConciseViewPositionMessage {
|
||||
Set-StrictMode -Off
|
||||
|
||||
$resetColor = ''
|
||||
if ($Host.UI.SupportsVirtualTerminal) {
|
||||
@@ -880,7 +881,7 @@ namespace System.Management.Automation.Runspaces
|
||||
|
||||
if ($myinv -and $myinv.ScriptName -or $_.CategoryInfo.Category -eq 'ParserError') {
|
||||
if ($myinv.ScriptName) {
|
||||
$posmsg = ""error in${resetcolor} $($myinv.ScriptName)${newline}""
|
||||
$posmsg = ""${resetcolor}$($myinv.ScriptName)${newline}""
|
||||
}
|
||||
else {
|
||||
$posmsg = ""${newline}""
|
||||
@@ -901,8 +902,12 @@ namespace System.Management.Automation.Runspaces
|
||||
$line = $myinv.Line
|
||||
$highlightLine = $myinv.PositionMessage.Split('+').Count - 1
|
||||
$offsetLength = $myinv.PositionMessage.split('+')[$highlightLine].Trim().Length
|
||||
$line = $line.Insert($myinv.OffsetInLine - 1 + $offsetLength, $resetColor)
|
||||
$line = $line.Insert($myinv.OffsetInLine - 1, $errorColor)
|
||||
|
||||
# don't color the whole line red
|
||||
if ($offsetLength -lt $line.Length - 1) {
|
||||
$line = $line.Insert($myinv.OffsetInLine - 1 + $offsetLength, $resetColor).Insert($myinv.OffsetInLine - 1, $accentColor)
|
||||
}
|
||||
|
||||
$posmsg += ""${accentColor}${lineWhitespace}$($myinv.ScriptLineNumber) ${verticalBar} ${resetcolor}${line}`n""
|
||||
$offsetWhitespace = ' ' * ($myinv.OffsetInLine - 1)
|
||||
$prefix = ""${accentColor}${headerWhitespace} ${verticalBar} ${errorColor}""
|
||||
@@ -965,7 +970,7 @@ namespace System.Management.Automation.Runspaces
|
||||
elseif ($_.CategoryInfo.Category) {
|
||||
$reason = $_.CategoryInfo.Category
|
||||
}
|
||||
elseif ($_CategoryInfo.Reason) {
|
||||
elseif ($_.CategoryInfo.Reason) {
|
||||
$reason = $_.CategoryInfo.Reason
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user