Fix ConciseView to not show the line information within the error messages (#11952)

This commit is contained in:
Steve Lee
2020-02-26 21:07:57 +05:00
committed by GitHub
parent d87472d368
commit 2db8516a8c
2 changed files with 8 additions and 1 deletions
@@ -1100,7 +1100,8 @@ namespace System.Management.Automation.Runspaces
$offsetInLine = 0
}
else {
$positionMessage = $myinv.PositionMessage.Split($newline)
# use newline char instead of $newline because that is what is in the message
$positionMessage = $myinv.PositionMessage.Split(""`n"")
$line = $positionMessage[1].Substring(1) # skip the '+' at the start
$highlightLine = $positionMessage[$positionMessage.Count - 1].Substring(1)
$offsetLength = $highlightLine.Trim().Length
@@ -99,6 +99,12 @@ Describe 'Tests for $ErrorView' -Tag CI {
$e = { throw "$msg" } | Should -Throw $msg -PassThru | Out-String
$e | Should -BeLike "*$msg*"
}
It "Position message does not contain line information" {
$e = & "$PSHOME/pwsh" -noprofile -command "foreach abc" | Out-String
$e | Should -Not -BeLike "*At line*"
}
}
Context 'NormalView tests' {