diff --git a/src/progress.rs b/src/progress.rs index 5e0e4cd16..e23ba0842 100644 --- a/src/progress.rs +++ b/src/progress.rs @@ -63,8 +63,8 @@ impl Progress { } let bar_width = ui - .size() - .map(|(cols, _rows)| usize::from(cols)) + .term_width() + .map(usize::from) .unwrap_or(0) .saturating_sub(self.buffer.len() - control_chars + 2); self.buffer.push('['); diff --git a/src/ui.rs b/src/ui.rs index 5047b5427..e9919eac6 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -288,8 +288,8 @@ impl Ui { rpassword::prompt_password(format!("{prompt}: ")) } - pub fn size(&self) -> Option<(u16, u16)> { - crossterm::terminal::size().ok() + pub fn term_width(&self) -> Option { + crossterm::terminal::size().ok().map(|(cols, _)| cols) } /// Construct a guard object which writes `data` when dropped. Useful for