Repository navigation
Format-Table -Wrap produces strange output for a mix of long lines and lines containing tabs #6313
Description
Activity
Anotehr bit of strange behavior for
@(( New-Object psobject | Add-Member -Passthru Foo "a`tb" ), ( New-Object psobject | Add-Member -Passthru Foo ("c`t" + 'd' * 100 + ' ' + 'd' * 100) ), ( New-Object psobject | Add-Member -Passthru Foo "e`tf" )) | ft -Wrap
PS 5.0:
PS Core:
There is now also an empty line between the two parts of the wrapping second row. This line does not go away if I replace the tab in the first row with spaces, but does go away if I replace the tab in the second row with spaces.
Arnav Singh (@Arnavion) Thanks for you report. Could you please repo with later daily build?
- addedWG-Interactive-Consolethe console experiencethe console experience
on Mar 6, 2018 Arnav Singh (@Arnavion) Thanks for the repo.
/cc Steve Lee (@SteveL-MSFT) Could you please comment the Issue?
Looks like a bug in the wrapping logic. I'll look into this.
Reacted by IlyaThe way
-Wrapworks is that it tries not to split a word. So in the second case above (w/ latest master), the wrap inserts a newline after the first'd' * 100since it fits, but puts the second one on a new line rather than split it. In the first case, the tab character's display size isn't taken into account, so it treats it as size 1.'d' * 200is wider than the width of the console, so it has to split it in half, but due to the wrong total length calculation of the tab, it inserts the newline in the wrong place.Not sure how to fix this for all cases. On macOS, the default tab stop is 8, so
a`tbwould show "a<seven spaces>b". However you can usetabs -4to change the tab stop to 4 or even set different sizes for tab stop 1, 2, ... so we can't make assumptions about the tab stops.I suppose one option is when using
format-table -wrap, we convert the tabs to four spaces.I guess there is many kinds of terminals with exclusive settings - easiest way for PowerShell is to ignore a terminal (tab) settings and use its own settings. (We could have
PSTabExpansion.) Although this may not work well when the window size is changed.There are already some places in the PowerShell code base that replaces tabs with four spaces, although it's not consistent everywhere.
microsoft-github-policy-service commented
on Nov 16, 2023 ContributorMore actionsThis issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented
on Nov 16, 2023 ContributorMore actionsThis issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
- addedResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or more
on Nov 16, 2023 microsoft-github-policy-service commented
on Nov 16, 2023 ContributorMore actionsThis issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented
on Nov 23, 2023 ContributorMore actionsThis issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.



Steps to reproduce
Windows 7, with pwsh.exe's window size set to 200x75. The width is the relevant thing. Choice of font does not seem to matter.
Edit: Also repros on openSUSE Tumbleweed in a similarly sized ssh window or konsole window.
Expected behavior
(from PS 5)
Actual behavior
There is an extra line after the first and last element (in fact there is an extra line after every row except the one with the wrapping value)
The row that has the long value is wrapped strangely.
Environment data
and
Removing the tab character from the first object's property (or even replacing it with 8 spaces) fixes the extra line between the rows but does not fix the strange wrapping of the long row.
Shortening the long row so that it does not need to wrap also fixes the extra line between the rows.