Vscode-powershell: Powershell Integrated Console colors wrong

Created on 30 May 2017  路  11Comments  路  Source: PowerShell/vscode-powershell

The Powershell IC doesn't display certain background and foreground colors the same as the ISE and CMD.Exe shell.

Main issue is a Background color of BLACK shows up as white, GRAY shows up as dark gray, DARK GRAY shows up as gray, and WHITE shows up as a third gray.

Also, when foreground and background are the same color, the IC defaults to white on white.

Simple script to test

$FGcolors = [enum]::GetValues([System.ConsoleColor])
$BGcolors = [enum]::GetValues([System.ConsoleColor])
$size = 10 

Write-Host "".PadRight($Size).Substring(0,$size) -NoNewline
Foreach ($BGcolor in $BGcolors) {
    Write-Host $BGcolor.ToString().PadRight($Size).Substring(0,$size)  -BackgroundColor $BGcolor -NoNewline
}
Write-Host 
Foreach ($FGcolor in $FGcolors) {
    Write-Host  $FGColor.ToString().PadRight($Size).Substring(0,$size) -foreground $FGColor -NoNewline

    Foreach ($BGcolor in $BGcolors)
    {
         Write-Host   $FGColor.ToString().PadRight($Size).Substring(0,$size) -background $BGColor -foreground $FGColor -nonewline
    }
    Write-Host 
}

Powershell IC
image

Powershell ISE
image

CMD.EXE running Powershell
image

System Details

  • Operating system name and version: Win 7
  • VS Code version: 1.12.2
  • PowerShell extension version: 1.1.0
  • Output from $PSVersionTable:
Name                           Value
----                           -----
PSVersion                      5.1.14409.1005
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1005
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
Area-Integrated Console Issue-Bug vscode-bug

Most helpful comment

I don't know if this is a related issue, but I'm having some trouble with colors too...

Powershell
powershell

VS Code
vscode

It may be a problem with Pshazz (it works fine on powershell, though).

All 11 comments

Thanks for the repro script Chris! Seems like this may be an issue with VS Code's terminal implementation, I get the same results both in the PowerShell Integrated Console and the normal integrated terminal running powershell.exe.

Here's what it looks like for me from within powershell.exe (ignore the exact colors, I'm using a theme):

image

Hey @Tyriar, do you have any ideas on what might be going on with the terminal colors here?

So winpty will transform the powershell colors to xterm escape sequences that are read and displayed by xterm.js. AFAIK there is no issue with the xterm.js logic so maybe there is a problem with winpty translating these?

I don't know if this is a related issue, but I'm having some trouble with colors too...

Powershell
powershell

VS Code
vscode

It may be a problem with Pshazz (it works fine on powershell, though).

@NemoStein I think this normally happens when you tweak the default colors of cmd.exe

I think I may have found a work around for the color formatting issues with the integrate console on windows. I have tried changing or resetting colors of powershell to no avail, but enabling the 'Use legacy console (requires relaunch)' checkbox appears to resolve my ongoing issues with an unreadable integrated terminal due to what appears to be improper background colors for text.

To reach the settings, open a powershell, and right click the title window and select properties > options.
Enable 'Use legacy console (requires relaunch)'. (Restarting VScode and/or all open Powershells may be needed. I don't know.)
console fix

After enabling this, my vscode integrated terminal appears work exactly as expected now after months of incorrect formatting.

@confusingbits I'm having the same issue, however if I enable legacy console then wsl (or bash on windows) doesn't work given it's unsupported according to this:

Unsupported console settings. In order to use this feature the legacy console must be disabled.

@hahn-kev I eventually ran into the same issue with WSL and had to revert. I don't have a solution.

Given that this repros in the "normal" (non-integrated) PowerShell terminal in VSCode, I think this issue should be moved to the VSCode repo. There is nothing this extension can do to fix this issue. If you disagree please feel free to re-open.

Also the syntax highlighting is missing from the integrated console. If you open a powershell window on windows 10 it will highlight comments, variables, etc with different colors in-line and in the display area. VScode shows it just monocolor.

@hypercube33, that highlighting is performed by a module called PSReadLine. Please see https://github.com/PowerShell/vscode-powershell/issues/535.

Was this page helpful?
0 / 5 - 0 ratings