Skip to content
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

Progress is Incorrectly Displayed #119

Closed
StartAutomating opened this issue Jul 7, 2019 · 1 comment · Fixed by #167
Closed

Progress is Incorrectly Displayed #119

StartAutomating opened this issue Jul 7, 2019 · 1 comment · Fixed by #167

Comments

@StartAutomating
Copy link

StartAutomating commented Jul 7, 2019

The helper function Wait-JobWithAnimation incorrectly handles progress, and this makes it look quite ugly indeed in the ISE (a spew of non-wrapped yellow lines).

The root of the problem is that you are creating your own Write-Progress. Please use Write-Progress instead, as this is more standard and will be honored across more PowerShell hosts.

The issue reproduces everywhere, but is worst in the PowerShell ISE.
PowerShellForGitHub version: 0.8.0
$psVersionTable
Name Value


PSVersion 5.1.17763.503
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.503
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1


To detail the fix:
Create an ID before the while loop (Line 57)

Change your Write-InteractiveHost to Write-Progress (line 94)
Write-Progress "$($animationFrames[$($iteration % $($animationFrames.Length))])" "Elapsed: $([int]($iteration / $framesPerSecond)) second(s)" -PercentComplete $((($iteration % $($animationFrames.Length)) / $animationFrames.Length) * 100) -id $id

Complete the Progress message at the end (lines 101 & 108)

Get rid of your Write-InteractiveHost at the very end

@HowardWolosky
Copy link
Member

Interesting. Thanks for the report! Want to submit a PR with this suggested change for me to check out? It's also possible to use -NoStatus to avoid seeing any of that progress being reported out.

HowardWolosky added a commit to HowardWolosky/PowerShellForGitHub that referenced this issue May 12, 2020
When this module was originally written, it used a special feature
of Write-Host in order to re-write the previously written line, in
order to show the user an indeterminate waiting indicator while the
module awaited a response from the server for a REST API request.

Unfortunately, this doesn't work well with all PowerShell hosts
(PowerShell ISE is one notable example).  This approach had been taken
originally as it had seemed odd to use Write-Progress (which displays
an absolute progress percentage) for something where we didn't absolutely
know the final duration.

This change migrates the module over to use Write-Progress, and simply
loops through the displayed percentage completed in the same manor that
it loops through and shows an animation.

This method should achieve the same desired goal (letting users know
that something is happening and that they just need to wait a bit
longer) in a more standards-approved way.

Resolve microsoft#119
HowardWolosky added a commit that referenced this issue May 12, 2020
When this module was originally written, it used a special feature
of Write-Host in order to re-write the previously written line, in
order to show the user an indeterminate waiting indicator while the
module awaited a response from the server for a REST API request.

Unfortunately, this doesn't work well with all PowerShell hosts
(PowerShell ISE is one notable example).  This approach had been taken
originally as it had seemed odd to use Write-Progress (which displays
an absolute progress percentage) for something where we didn't absolutely
know the final duration.

This change migrates the module over to use Write-Progress, and simply
loops through the displayed percentage completed in the same manor that
it loops through and shows an animation.

This method should achieve the same desired goal (letting users know
that something is happening and that they just need to wait a bit
longer) in a more standards-approved way.

Resolves #119
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 a pull request may close this issue.

2 participants