From d339d455319a706a034e56fdeadf8ce5418e9bd1 Mon Sep 17 00:00:00 2001 From: Paddy <89168564+patrickballard@users.noreply.github.com> Date: Mon, 26 Oct 2026 19:03:23 +0000 Subject: [PATCH] fix(desktop-gpui): carry a rounded-up minute in the timing cards The timing cards rounded the seconds after splitting off the minutes, so 59.96 s printed as 0:60.0 and 119.97 s as 1:60.0. Round to tenths first, with the same formatting, then split. --- apps/desktop-gpui/src/editor_panels.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/desktop-gpui/src/editor_panels.rs b/apps/desktop-gpui/src/editor_panels.rs index 1c77385670..a1da7a7862 100644 --- a/apps/desktop-gpui/src/editor_panels.rs +++ b/apps/desktop-gpui/src/editor_panels.rs @@ -6233,7 +6233,11 @@ impl EditorWindow { /// `formatTime` -- the `M:SS` clock the timing cards print, as `H:MM:SS` from /// an hour on. fn format_time(seconds: f64) -> String { - let seconds = seconds.max(0.); + // Round to tenths before splitting, so 59.96 carries into the next minute + // instead of printing as 0:60.0. + let seconds: f64 = format!("{:.1}", seconds.max(0.)) + .parse() + .unwrap_or_default(); let hours = (seconds / 3600.).floor() as u32; let seconds = seconds - f64::from(hours) * 3600.; let minutes = (seconds / 60.).floor() as u32; @@ -8432,6 +8436,15 @@ mod tests { assert_eq!(format_time(3905.5), "1:05:05.5"); } + #[test] + fn the_timing_cards_carry_a_rounded_up_minute() { + assert_eq!(format_time(59.94), "0:59.9"); + assert_eq!(format_time(59.96), "1:00.0"); + assert_eq!(format_time(119.97), "2:00.0"); + assert_eq!(format_time(3599.96), "1:00:00.0"); + assert_eq!(format_time(3659.99), "1:01:00.0"); + } + // -- Text presets ------------------------------------------------------ /// A brand-new text segment. `TextSegment` has no `Default` -- every field