diff --git a/CHANGELOG.md b/CHANGELOG.md index 78f3f4f..9474603 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Skip unplayable tracks - Queue UI correctly plays a track when clicking on an already selected item - Swap foreground and background colors for command line input +- Do not crash due to unavailable tracks in queue ## [1.2.2] diff --git a/src/ui/statusbar.rs b/src/ui/statusbar.rs index e4800ba..8bbfb63 100644 --- a/src/ui/statusbar.rs +++ b/src/ui/statusbar.rs @@ -190,8 +190,10 @@ impl View for StatusBar { if let Some(t) = self.queue.get_current() { printer.with_color(style_bar, |printer| { - let duration_width = - (((printer.size.x as u32) * elapsed_ms) / t.duration()) as usize; + let duration_width = elapsed_ms + .checked_mul(printer.size.x as u32) + .and_then(|v| v.checked_div(t.duration())) + .unwrap_or(0) as usize; printer.print((0, 0), &"━".repeat(duration_width + 1)); }); }