Closed
Description
Table width not calculated correct when using VT100.
https://docs.microsoft.com/en-us/powershell/wmf/5.1/console-improvements states "PowerShell will ignore certain VT100 formatting escape sequences when calculating table widths". This is true in "plain" PowerShell, but not in VSCode.
This example demonstrates the problem:
# Create object with VT100 escape sequences
$x = [PSCustomObject]@{
A = 'NoColor'
B = "$([char](27))[33;1mColor$([char](27))[0m"
C = 'NoColor'
}
# Auto size the columns
$x
# Set column width to 10
$x | Format-Table -Property @{L='A';E={$_.A};W=10},@{L='B';E={$_.B};W=10},@{L='C';E={$_.C};W=10}
# Column width is only 4 - this does not work anywhere!
$x | Format-Table -Property @{L='A';E={$_.A};W=4},@{L='B';E={$_.B};W=4},@{L='C';E={$_.C};W=4}
This example...:
- Does not work in VSCode - the VT100 sequence characters is included in the character count for table width
- Works in "plain" PowerShell on Windows 10 (not the four wide example)
- Does not work in ISE (but $host.UI.SupportsVirtualTerminal is $false - so VT100 doesn't work at all here)