Clear line properly for download progress#1781
Merged
kinnison merged 1 commit intorust-lang:masterfrom Apr 21, 2019
solson:master
Merged
Clear line properly for download progress#1781kinnison merged 1 commit intorust-lang:masterfrom solson:master
kinnison merged 1 commit intorust-lang:masterfrom
solson:master
Conversation
The workaround here that was printing many spaces did not work properly if the line length got very long and then very short again. I noticed this problem on an old version of rustup that still suffered from #1696, so it might not technically be reproducible anymore, but I figured we might as well fix this for the future anyway! I suspect the comment saying `delete_line()` didn't clear the line properly was attempting to call it *after* printing the current download progress, but the `term` crate docs say it deletes from the cursor position to the end of the line. To deal with that, we instead jump to the start of the line *before* printing the current download progress and call `delete_line()` there.
kinnison
approved these changes
Apr 21, 2019
Contributor
kinnison
left a comment
There was a problem hiding this comment.
LGTM, thank you for this.
kinnison
added a commit
to kinnison/rustup
that referenced
this pull request
Apr 22, 2019
In rust-lang#1781, we switched to using `delete_line()` but unfortunately that turns out to not work very well on Windows. So this commit turns us back to using spaces to erase things, but in a way which ought to be moderately more robust than before. There's still no guarantee we're doing it right, but at least this time if the terminal is approximately wide enough for the bar and no more, we won't be flowing onto the next line with loads of spaces after the rest of the tracker. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
kinnison
added a commit
to kinnison/rustup
that referenced
this pull request
Apr 22, 2019
In rust-lang#1781, we switched to using `delete_line()` but unfortunately that turns out to not work very well on Windows. So this commit turns us back to using spaces to erase things, but in a way which ought to be moderately more robust than before. There's still no guarantee we're doing it right, but at least this time if the terminal is approximately wide enough for the bar and no more, we won't be flowing onto the next line with loads of spaces after the rest of the tracker. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The workaround here that was printing many spaces did not work properly if the line length got very long and then very short again. I noticed this problem on an old version of rustup that still suffered from #1696, so it might not technically be reproducible anymore, but I figured we might as well fix this for the future anyway!
I suspect the comment saying
delete_line()didn't clear the line properly was attempting to call it after printing the current download progress, but thetermcrate docs say it deletes from the cursorposition to the end of the line.
To deal with that, we instead jump to the start of the line before printing the current download progress and call
delete_line()there.