Skip to content

Commit

Permalink
avoid negative repeat_count fixes dandavison#1760
Browse files Browse the repository at this point in the history
  • Loading branch information
lrfurtado committed Jul 17, 2024
1 parent 5d538b2 commit fffa015
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/paint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,14 @@ impl<'p> Painter<'p> {
Painter::right_fill_background_color(&mut line, fill_style);
} else if let Some(BgFillMethod::Spaces) = bg_fill_mode {
let text_width = ansi::measure_text_width(&line);
let mut repeat_count:usize = 0;
if text_width < config.available_terminal_width {
repeat_count = config.available_terminal_width - text_width;
}
line.push_str(
#[allow(clippy::unnecessary_to_owned)]
&fill_style
.paint(" ".repeat(config.available_terminal_width - text_width))
.paint(" ".repeat(repeat_count))
.to_string(),
);
} else if line_is_empty {
Expand Down

0 comments on commit fffa015

Please sign in to comment.