max_len should always be non-zero

pull/369/head
Wilfred Hughes 2022-09-11 17:26:55 +07:00
parent 2e22d19600
commit 35878fcc2b
1 changed files with 2 additions and 0 deletions

@ -104,6 +104,8 @@ pub fn split_and_apply(
styles: &[(SingleLineSpan, Style)],
side: Side,
) -> Vec<String> {
assert!(max_len > 0);
if styles.is_empty() && !line.trim().is_empty() {
// Missing styles is a bug, so highlight in purple to make this obvious.
return split_string_by_width(line, max_len, matches!(side, Side::Left))