Closed
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Console output truncated with an ellipsis causes remaining text to shift to the left when using $PSStyle
I have a .ps1xml format file that defines a view for file and directory objects which uses $PSStyle to highlight parts of the output, e.g.:
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<SelectionSets>
<SelectionSet>
<Name>FileSystemTypes</Name>
<Types>
<TypeName>System.IO.DirectoryInfo</TypeName>
<TypeName>System.IO.FileInfo</TypeName>
</Types>
</SelectionSet>
</SelectionSets>
<ViewDefinitions>
<View>
<Name>children</Name>
<ViewSelectedBy>
<SelectionSetName>FileSystemTypes</SelectionSetName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader> <Label>Name</Label> <Width>30</Width> <Alignment>Left</Alignment> </TableColumnHeader>
<TableColumnHeader> <Label>LastWriteTime </Label> <Width>19</Width> <Alignment>Left</Alignment> </TableColumnHeader>
<TableColumnHeader> <Label>Size </Label> <Width>10</Width> <Alignment>Right</Alignment> </TableColumnHeader>
<TableColumnHeader> <Label>FullName</Label> <Alignment>Left</Alignment> </TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<ScriptBlock>
"$($PSStyle.Reverse)$($_.Name)$($PSStyle.Reset)"
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
$_.LastWriteTime.ToString('yyyy-MM-dd HH:mm:ss')
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
($_.Length/1MB).ToString('0.000')+' MB'
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
$_.FullName
</ScriptBlock>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>
$filePath = 'D:\my.format.ps1xml'
Update-FormatData -PrependPath $filePath
Get-ChildItem -Path $PSHOME -File
When the Name
column contains a long file name, the console truncates the name and adds an ellipsis …
to indicate that there are truncated characters. When this happens, the remaining characters on the line are shifted 3 spaces to the left:
Removing the references to $PSStyle in the .ps1xml format file gives the expected layout:
The shift effect is present for any value of $PSStyle.OutputRendering.
Expected behavior
Output text on lines with a truncation ellipsis should remain aligned with its column header.
Actual behavior
Output text on lines with a truncation ellipsis is shifted to the left.
Error details
n/a
Environment data
Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Microsoft Windows 10.0.19043
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response