Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/cli/download_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ impl DownloadTracker {
let speed = if len > 0 { sum / len as f64 } else { 0. };
let speed_h = HumanReadable(speed);

// First, move to the start of the current line and clear it.
let _ = self.term.as_mut().unwrap().carriage_return();
let _ = self.term.as_mut().unwrap().delete_line();

match self.content_len {
Some(content_len) => {
let content_len = content_len as f64;
Expand All @@ -156,11 +160,9 @@ impl DownloadTracker {
);
}
}
// delete_line() doesn't seem to clear the line properly.
// Instead, let's just print some whitespace to clear it.
let _ = write!(self.term.as_mut().unwrap(), " ");

// Since stdout is typically line-buffered and we don't print a newline, we manually flush.
let _ = self.term.as_mut().unwrap().flush();
let _ = self.term.as_mut().unwrap().carriage_return();
self.displayed_progress = true;
}
}
Expand Down