Skip to content

Format-Table does not return null if the Console width is equal to 0. - #6883

Closed
Klaudia Algiz (kalgiz) wants to merge 12 commits into
PowerShell:masterfrom
kalgiz:format-table-bug-fix
Closed

Klaudia Algiz (kalgiz) wants to merge 12 commits into
PowerShell:masterfrom
kalgiz:format-table-bug-fix

Conversation

@kalgiz

@kalgiz Klaudia Algiz (kalgiz) commented May 16, 2018 •

Copy link
Copy Markdown
Contributor

PR Summary

Format-Table does not return null if the Console width is equal to 0.
Fixes: #6748

PR Checklist


This change is Reviewable

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we should use try {} finally {} to ensure that the hook was turned off.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we check that console width is default (120)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe add in the comment that VSTS console width is 0 and we address this.

@iSazonov Ilya (iSazonov) May 18, 2018 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The test (console width is default (120)) failed and this say the we have broken hook - Console.WindowWidth = 0 doesn't work.
The hook should be here:

if (Console.WindowWidth == 0 || InternalTestHooks.SetConsoleWidthToZero)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The test is failed. It is incorrect test. Console.WindowWidth = 0 doesn't work.
We should have another way.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Klaudia Algiz (@kalgiz) Please address the comment.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please replace aliases and correct formatting.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please add new line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@iSazonov

Copy link
Copy Markdown
Collaborator

Klaudia Algiz (@kalgiz) The PR contains alien commits - please rebase.

@kalgiz

Copy link
Copy Markdown
Contributor Author

Ilya (@iSazonov) I made the rebase.

@iSazonov

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT) Aditya Patwardhan (@adityapatwardhan) Could you please review?

# Fill the console window with the string, so that it reaches its max width.
# Check if the max width is equal to default value (120), to test test hook set.
$testObject = @{ test = '1' * 200}
Format-Table -inputobject $testObject | Out-String -str | ForEach-Object {$_.length} | Sort-Object | Select-Object -Last 1 | Should -Be 120

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

-str should be -Stream

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Klaudia Algiz (@kalgiz) Can you make these changes?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Aditya Patwardhan (@adityapatwardhan) can you make that change in this PR so we can still take this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@stale

stale Bot commented Jul 12, 2018

Copy link
Copy Markdown

This PR has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs within 10 days.
Thank you for your contributions.
Community members are welcome to grab these works.

@stale stale Bot added Stale and removed Stale labels Jul 12, 2018
Travis Plunk (TravisEz13) added a commit to TravisEz13/PowerShell that referenced this pull request Aug 7, 2018
Travis Plunk (TravisEz13) added a commit to TravisEz13/PowerShell that referenced this pull request Aug 7, 2018
@TravisEz13

Copy link
Copy Markdown
Member

replaced by #7465

Travis Plunk (TravisEz13) added a commit that referenced this pull request Aug 7, 2018
Default to DefaultConsoleWidth when DotNet says WindowWidth is 0

This resolves an issue in an environment like VSTS when pwsh is spawned and DotNet is not able to determine the Console Width.
* Port changes from #6883 by @kalgiz
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
…erShell#7465)

Default to DefaultConsoleWidth when DotNet says WindowWidth is 0

This resolves an issue in an environment like VSTS when pwsh is spawned and DotNet is not able to determine the Console Width.
* Port changes from PowerShell#6883 by @kalgiz
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.

Format-Table doesn't work when run on vsts.

5 participants