Skip to content

Commit

Permalink
Avoid try/catch for 'DarkYellow'
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlbyk committed Oct 27, 2020
1 parent 0e20dfb commit d92146c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/AnsiUtils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ function Get-VirtualTerminalSequence ($color, [int]$offset = 0) {
return "${AnsiEscape}$(38 + $offset);2;${r};${g};${b}m"
}

# Force 'DarkYellow' to ConsoleColor, since it is not an HTML color
if ($color -eq [ConsoleColor]::DarkYellow) {
$color = [ConsoleColor]::DarkYellow
}

if ($color -is [String]) {
try {
if ($ColorTranslatorType) {
Expand All @@ -73,11 +78,6 @@ function Get-VirtualTerminalSequence ($color, [int]$offset = 0) {
catch {
Write-Debug $_
}

# Hard to get here but DarkYellow is not an HTML color but it is a ConsoleColor
if (($color -isnot $ColorType) -and ($null -ne ($consoleColor = $color -as [System.ConsoleColor]))) {
$color = $consoleColor
}
}

if ($ColorType -and ($color -is $ColorType)) {
Expand Down

0 comments on commit d92146c

Please sign in to comment.