8000 Fix `Minimal` ProgressView to handle Activity that is longer than console width by SteveL-MSFT · Pull Request #15264 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Fix Minimal ProgressView to handle Activity that is longer than console width #15264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 17, 2021

Conversation

SteveL-MSFT
Copy link
Member
@SteveL-MSFT SteveL-MSFT commented Apr 18, 2021

PR Summary

The current code handles the case where Status is too long, but doesn't handle the case where Activity is longer than console width so that when calculating the space for status, it becomes a negative value. Fix is to check if Activity is longer than the console width and truncate it so that it doesn't take up more than half the console width allowing space for the Status.

PR Context

Fix #15251

PR Checklist

Copy link
Collaborator
@iSazonov iSazonov left a comment

Choose a reason for hiding this comment

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

Another concern is the code very complex and we can catch issues with it again and again. Why not use old approach? (I mean RenderFullDescription)

string activity;
if (Activity.Length > maxWidth / 2)
{
activity = Activity.Substring(0, maxWidth / 2) + PSObjectHelper.Ellipsis;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looking on Archive expand example in #14414 I think we break the scenario.

Copy link
Member Author

Choose a reason for hiding this comment

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

I just tried expand-archive with this branch and works fine with a narrow console window. As expected, activity and status are truncated.

Copy link
Collaborator
@iSazonov iSazonov Apr 21, 2021

Choose a reason for hiding this comment

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

I guess they are truncated too early while there is still a lot of free space on the right.

[1234567890          ]
[12345678        ]

Copy link
Member Author

Choose a reason for hiding this comment

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

The bar area is also used for Status text which can change as progress is being written. So it's possible to fill up as much of Activity and Status as possible so whitespace is limited, it would also mean that the Status area would resize if the text changes which would make it hard to read.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I tried the build and I see the resizing scenario doesn't work at all. But this doesn't depend on the PR.
Run follow and use mouse to change windows width:

1..100 | % { Write-Progress -Activity "123456789012345678901234567890123456789012345678901234567890" -Status "S" -PercentComplete $_ -SecondsRemaining $_ ; Sleep 1}

Results:

  • after size changed (both left and right directions) the progress bar doesn't work
  • screen destroyed
  • after the command finished (or Ctrl-C pressed) screen buffer destroyed
  • instead of final Ellipsis I see single dot (direct output Ellipsis works on the console

(only last related to the PR)

Copy link
Member

Choose a reason for hiding this comment

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

@iSazonov Can you please take another look and see if you have any outstanding concerns for the changes in this particular PR? For the points you brought up above in #15264 (comment), they look like out of the scope of this PR (correct me if I'm wrong), and maybe track them in a separate issue?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@daxian-dbw This removes the exception but I personally do not like the result of the display, although it is not fundamental. The fundamental thing is that the resizing scenario works horribly. But I don't see the point of opening a new issue since MSFT team doesn't have the resources to fix 3000 issues anyway.

Copy link
Member

Choose a reason for hiding this comment

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

I opened #15407 to track the resizing issue.

instead of final Ellipsis I see single dot (direct output Ellipsis works on the console

image

@SteveL-MSFT It does look weird to have a single dot instead of Ellipsis when truncation happens. Should that be addressed in this PR or you think it should be a separate one?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll take a look at the other issues in a separate PR since this specific issue is affecting users with real world scenarios

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good. #15412 is opened to track the review comment.

@ghost ghost added the Review - Needed The PR is being reviewed label Apr 29, 2021
@ghost
Copy link
ghost commented Apr 29, 2021

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

Copy link
@anmenaga anmenaga left a comment

Choose a reason for hiding this comment

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

LGTM

@daxian-dbw daxian-dbw added CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log and removed Review - Needed The PR is being reviewed labels May 13, 2021
@SteveL-MSFT
Copy link
Member Author

Codefactor issue is "won't fix"

@ghost
Copy link
ghost commented May 27, 2021

🎉v7.2.0-preview.6 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ProgressView Minimal - Copy-Item error when copying to/from pssession
4 participants
0