Fill all last text to space and return the cursor

This commit is contained in:
Edwin Cheng 2019-11-27 05:01:13 +08:00
parent 27943bead6
commit f0aaf3b296

View file

@ -107,7 +107,14 @@ impl ProgressReport {
}
fn clear(&mut self) {
print!("{}{}", " ".repeat(self.text.len()), "\x08".repeat(self.text.len()));
if self.hidden {
return;
}
// Fill all last text to space and return the cursor
let spaces = " ".repeat(self.text.len());
let backspaces = "\x08".repeat(self.text.len());
print!("{}{}{}", backspaces, spaces, backspaces);
self.text = String::new();
}
}