8000 correctly presenting progressbar when buffer scrolls and clearing at end by SteveL-MSFT · Pull Request #3362 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

correctly presenting progressbar when buffer scrolls and clearing at end #3362

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 1 commit into from
Mar 19, 2017

Conversation

SteveL-MSFT
Copy link
Member

Windows progressbar requires ability to cache the screen buffer contents so it can write it back once progress is done. Linux doesn't provide a way for console apps to read the screen buffer (security concern). Changes:

  • scroll buffer appropriately by the size needed for progress bar if near bottom of screen, adjust progressbar location to account for scrolling
  • create an empty screen buffer used to clear the progress bar once done

No easy way to add tests for ProgressBar.

addresses #1625

Before the change:
before

After the change:
after

if (_location.Y >= _rawui.BufferSize.Height - rows)
//if the cursor is at the bottom, create screen buffer space by scrolling
int scrollRows = rows - ((_rawui.BufferSize.Height - 1) - _location.Y);
for (int i = 0; i < rows; i++)
Copy link
Contributor

Choose a reason for hiding this comment

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

In rare cases, there may be junk on the screen below the prompt. Maybe we should be writing out spaces to make sure it's clear.

Copy link
Member Author

Choose a reason for hiding this comment

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

If there's junk, it'll get overwritten anyways with tempProgressRegion where every cell has a character including spaces

@lzybkr lzybkr self-assigned this Mar 19, 2017
@lzybkr lzybkr merged commit 30eb61e into PowerShell:master Mar 19, 2017
@iSazonov
Copy link
Collaborator
iSazonov commented Mar 19, 2017

No easy way to add tests for ProgressBar.

We can try to use our TestHostCS.psm1

@SteveL-MSFT SteveL-MSFT deleted the progressbar-2 branch March 19, 2017 23:21
@SteveL-MSFT
Copy link
Member Author

@iSazonov don't think TestHostCS.psm1 will help here since we're trying to validate how powershell.exe handles progressbar

@lzybkr
Copy link
Contributor
lzybkr commented Mar 20, 2017

Testing this would be similar to how I test PSReadline - I introduce a mock console interface, so instead of Console.Write, you write something more like _console.Write - then the test framework has a mock for the interface (which doesn't really exist, you need to invent one.)

It's a pain to write these tests and there is little return in that investment, so that's why I didn't ask Steve for any tests.

@iSazonov
Copy link
Collaborator

there is little return in that investment

If the stock price change, I may try to enhance our TestHostCS.psm1 to support this scenarios. 😄

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.

4 participants
0