diff --git a/src/ui.rs b/src/ui.rs index 0f3a57b26..cf7e8ae60 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -278,11 +278,7 @@ impl Ui { } pub fn term_width(&self) -> Option { - if let Some(cols) = env::var("COLUMNS").ok().and_then(|s| s.parse().ok()) { - Some(cols) - } else { - crossterm::terminal::size().ok().map(|(cols, _)| cols) - } + term_width() } /// Construct a guard object which writes `data` when dropped. Useful for @@ -337,3 +333,11 @@ impl Drop for OutputGuard { _ = self.output.flush(); } } + +fn term_width() -> Option { + if let Some(cols) = env::var("COLUMNS").ok().and_then(|s| s.parse().ok()) { + Some(cols) + } else { + crossterm::terminal::size().ok().map(|(cols, _)| cols) + } +}