Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ private StringCollection GenerateMultiLineRowField(string val, int k, int alignm
{
StringCollection sc = StringManipulationHelper.GenerateLines(dc, val,
_si.columnInfo[k].width, _si.columnInfo[k].width);
if (addPadding)
if (addPadding || alignment == TextAlignment.Right)
{
// if length is shorter, do some padding
for (int col = 0; col < sc.Count; col++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,49 @@ abc bcd



"@ }
) {
param($obj, $expectedTable)
$output = $obj | Format-Table | Out-String
$output.Replace("`r","").Replace(" ",".").Replace("`n","^") | Should -BeExactly $expectedTable.Replace("`r","").Replace(" ",".").Replace("`n","^")
}

It "Should render header correctly where header is shorter than column width with justification: <variation>" -TestCases @(
@{ variation = "left/right"; obj = [PSCustomObject]@{a="abc";b=123}; expectedTable = @"

a b
- -
abc 123



"@ },
@{ variation = "left/left"; obj = [PSCustomObject]@{a="abc";b="abc"}; expectedTable = @"

a b
- -
abc abc



"@ },
@{ variation = "right/left"; obj = [PSCustomObject]@{a=123;b="abc"}; expectedTable = @"

a b
- -
123 abc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting,

  1. should we justify header fields? Maybe always have left/center/right justify?
  2. should we pad "-" to length of values not headers?
a   b
--- ---
123 abc

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but that's an enhancement. I would suggest opening a new issue to discuss that. This PR makes this consistent with Windows PowerShell existing behavior.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that this issue only happens on PS Core?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anmenaga yes, this is a regression in PSCore6.1




"@ },
@{ variation = "right/right"; obj = [PSCustomObject]@{a=123;b=123}; expectedTable = @"

a b
- -
123 123



"@ }
) {
param($obj, $expectedTable)
Expand Down