bugfix: Allow dust to work on low width terminal

Do not assume the min width is 80 (unless on windows).
This commit is contained in:
andy.boot
2021-09-19 11:13:11 +01:00
parent d6c2482150
commit 1cb731533b
+10
View File
@@ -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<Regex> {
match maybe_value {
Some(v) => match Regex::new(v) {