Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix Format-Table where rows were being trimmed unnecessarily if there's only one row of headers#6772

Merged
iSazonov merged 3 commits intoPowerShell:masterfrom
SteveL-MSFT:table-left-justifed
May 2, 2018
Merged

Fix Format-Table where rows were being trimmed unnecessarily if there's only one row of headers#6772
iSazonov merged 3 commits intoPowerShell:masterfrom
SteveL-MSFT:table-left-justifed

Conversation

@SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Apr 28, 2018

PR Summary

In the case where a row doesn't expand to multiple rows, columns were still being trimmed of whitespace which introduces invalid alignment as the whitespace needs to be retained.
Added new tests to cover this scenario. Updated some existing tests to use ^ instead of backtick to represent newline making it easier to replace it back with a newline to visualize during debugging when test fails.

Fix #6767

PR Checklist

don't trim columns in table if there's only one row
added tests
@SteveL-MSFT SteveL-MSFT requested a review from iSazonov April 28, 2018 22:22
@SteveL-MSFT SteveL-MSFT changed the title Fix Format-Table where headers were being trimmed unnecessarily if there's only one row of headers Fix Format-Table where rows were being trimmed unnecessarily if there's only one row of headers Apr 29, 2018

abc bcd
--- ---
1234 123
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should 4 be on new next line?

abc bcd
--- ---
123 123
4

Copy link
Member Author

Choose a reason for hiding this comment

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

That's only if there is a format file that specifies the width. When there isn't it will auto set the width of a column based on the first few samples of the output. So in this case, the 1234 dictate the width of column 1.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the fix (and the bug) for autosize only?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I believe so

Copy link
Collaborator

@iSazonov iSazonov Apr 30, 2018

Choose a reason for hiding this comment

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

Could you please add a comment or change the test header that it is a implicit autosize?
(Also we should add later tests for explicit -AutoSize.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated test description to make clear and added more rows to cover accidental trim of a row and not just header

address Ilya's feedback and added test to capture rows that got trimmed and not just header
@iSazonov iSazonov requested a review from TravisEz13 May 1, 2018 12:38
@SteveL-MSFT SteveL-MSFT requested a review from anmenaga May 1, 2018 14:31
@iSazonov iSazonov merged commit 77d10e9 into PowerShell:master May 2, 2018
@SteveL-MSFT SteveL-MSFT deleted the table-left-justifed branch May 2, 2018 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Titles misalignment

2 participants