Skip to content

Commit

Permalink
bugfix: Allow dust to work on low width terminal
Browse files Browse the repository at this point in the history
Do not assume the min width is 80 (unless on windows).
  • Loading branch information
bootandy committed Sep 19, 2021
1 parent d6c2482 commit 21d3f2b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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) {
Expand Down

0 comments on commit 21d3f2b

Please sign in to comment.