Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -766,14 +766,14 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_System_Management_Autom
$maxDepth = 10
$ellipsis = ""`u{2026}""
$resetColor = ''
if ($Host.UI.SupportsVirtualTerminal -and !(Test-Path env:__SuppressAnsiEscapeSequences)) {
if ($Host.UI.SupportsVirtualTerminal -and ([string]::IsNullOrEmpty($env:__SuppressAnsiEscapeSequences))) {
$resetColor = [System.Management.Automation.VTUtility]::GetEscapeSequence(
[System.Management.Automation.VTUtility+VT]::Reset
)
}

function Get-VT100Color([ConsoleColor] $color) {
if (!$Host.UI.SupportsVirtualTerminal -or (Test-Path env:__SuppressAnsiEscapeSequences)) {
if (!$Host.UI.SupportsVirtualTerminal -or !([string]::IsNullOrEmpty($env:__SuppressAnsiEscapeSequences))) {
return ''
}

Expand Down Expand Up @@ -1013,14 +1013,14 @@ private static IEnumerable<FormatViewDefinition> ViewsOf_System_Management_Autom
function Get-ConciseViewPositionMessage {

$resetColor = ''
if ($Host.UI.SupportsVirtualTerminal -and !(Test-Path env:__SuppressAnsiEscapeSequences)) {
if ($Host.UI.SupportsVirtualTerminal -and ([string]::IsNullOrEmpty($env:__SuppressAnsiEscapeSequences))) {
$resetColor = [System.Management.Automation.VTUtility]::GetEscapeSequence(
[System.Management.Automation.VTUtility+VT]::Reset
)
}

function Get-VT100Color([ConsoleColor] $color) {
if (!$Host.UI.SupportsVirtualTerminal -or (Test-Path env:__SuppressAnsiEscapeSequences)) {
if (!$Host.UI.SupportsVirtualTerminal -or !([string]::IsNullOrEmpty($env:__SuppressAnsiEscapeSequences))) {
return ''
}

Expand Down
8 changes: 7 additions & 1 deletion test/powershell/engine/Formatting/ErrorView.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,15 @@ Describe 'Tests for $ErrorView' -Tag CI {

It "Position message does not contain line information" {

$e = & "$PSHOME/pwsh" -noprofile -command "foreach abc" | Out-String
$e = & "$PSHOME/pwsh" -noprofile -command "foreach abc" 2>&1 | Out-String
$e | Should -Not -BeNullOrEmpty
$e | Should -Not -BeLike "*At line*"
}

It "Error shows if `$PSModuleAutoLoadingPreference is set to 'none'" {
$e = & "$PSHOME/pwsh" -noprofile -command '$PSModuleAutoLoadingPreference = ""none""; cmdletThatDoesntExist' 2>&1 | Out-String
$e | Should -BeLike "*cmdletThatDoesntExist*"
}
}

Context 'NormalView tests' {
Expand Down