Don't panic when the progress is > 1.0 (#2229)

Ratatui asserts that gauges don't have a progress greater than 1.0
This can happen if a dataset reports a lower len() than it actually provides.

This change prevents a panic when the `Progress::items_processed` is greater than the `Progress::items_total`
This commit is contained in:
Paul Wagener 2024-09-01 22:33:25 +02:00 committed by GitHub
parent 44030ead17
commit 23622d765d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -86,7 +86,7 @@ impl ProgressBarView {
let iteration = Gauge::default()
.gauge_style(Style::default().fg(Color::Yellow))
.ratio(self.progress);
.ratio(self.progress.min(1.0));
let eta = Paragraph::new(Line::from(vec![
Span::from(" ("),
Span::from(self.eta).italic(),