Skip to content
Permalink
Browse files

Fix panic when columns < NO_LANG_HEADER_ROW_LEN (#331)

$ cargo run -- --columns=66
    thread 'main' panicked at 'attempt to subtract with overflow',
    src/cli_utils.rs:64:17
  • Loading branch information...
ocisly authored and XAMPPRocky committed May 6, 2019
1 parent e10c19a commit c2a16656477840b153ef335c87ab2c1d783e04a1
Showing with 12 additions and 10 deletions.
  1. +12 −10 src/main.rs
@@ -47,16 +47,18 @@ fn main() -> Result<(), Box<Error>> {
process::exit(0);
}

let columns = cli.columns.or(config.columns).unwrap_or_else(|| {
if cli.files {
term_size::dimensions().map_or(FALLBACK_ROW_LEN, |(w, _)| {
w.max(FALLBACK_ROW_LEN)
})
} else {
FALLBACK_ROW_LEN
}
});

let columns = cli
.columns
.or(config.columns)
.or_else(|| {
if cli.files {
term_size::dimensions().map(|(w, _)| w)
} else {
None
}
})
.unwrap_or(FALLBACK_ROW_LEN)
.max(FALLBACK_ROW_LEN);

let row = "-".repeat(columns);

0 comments on commit c2a1665

Please sign in to comment.
You can’t perform that action at this time.