From 21d3f2bc7eb072af651ef42d8d70b193cdd30bc6 Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Sun, 19 Sep 2021 11:13:11 +0100 Subject: [PATCH] bugfix: Allow dust to work on low width terminal Do not assume the min width is 80 (unless on windows). --- src/main.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main.rs b/src/main.rs index 5445fed..fbd918b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,6 +64,7 @@ fn get_height_of_terminal() -> usize { } } +#[cfg(windows)] fn get_width_of_terminal() -> usize { // Windows CI runners detect a very low terminal width if let Some((Width(w), Height(_h))) = terminal_size() { @@ -73,6 +74,15 @@ fn get_width_of_terminal() -> usize { } } +#[cfg(not(windows))] +fn get_width_of_terminal() -> usize { + if let Some((Width(w), Height(_h))) = terminal_size() { + w as usize + } else { + DEFAULT_TERMINAL_WIDTH + } +} + fn get_regex_value(maybe_value: Option<&str>) -> Option { match maybe_value { Some(v) => match Regex::new(v) {