Skip to content

Format-Table output breaks with VT100/ANSI escape sequences #2755

Closed
@MartinGC94

Description

@MartinGC94

System Details Output

### VSCode version: 1.46.0-insider 9f89da69154ac6c99dfa7c82986e2df95b7bbe0b x64

### VSCode extensions:
ms-vscode.powershell-preview@2020.6.1

### PSES version: 2.2.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      5.1.19041.1
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

Output from Format-Table breaks inside the integrated console when you add vt100 sequences to change the colors. This works fine in every other terminal I've tried that supports this feature.
You can try this out with the following code:

$TableOutput=Get-NetIPAddress -AddressFamily IPv4 | Format-Table
$i=0
foreach ($Line in $TableOutput)
 {
     $FieldList=$Line.formatEntryInfo.formatPropertyFieldList

     if ($FieldList)
     {
        $i++
         if ($i%2 -eq 0)
         {
             foreach ($Property in $FieldList)
             {
                 $Property.propertyValue="$([char]27)[92m$($Property.propertyValue)$([char]27)[0m"
             }
         }
     }
 }
$TableOutput

Expected Behaviour

Expected

Actual Behaviour

Actual

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions