From d4704af4423b65c75c27b99073f939e05903bfdc Mon Sep 17 00:00:00 2001 From: hl-valdemar Date: Sat, 17 Oct 2026 23:08:52 +0200 Subject: [PATCH] fix: round final compact progress fraction to completion --- Checks/system-playback.swift | 1 + README.md | 2 +- Sources/App/TerebiApp.swift | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Checks/system-playback.swift b/Checks/system-playback.swift index 465236c..d486560 100644 --- a/Checks/system-playback.swift +++ b/Checks/system-playback.swift @@ -34,6 +34,7 @@ struct SystemPlaybackChecks { "compact time uses total-duration units, truncation and bounded progress: \(expected)") } for (position, expected) in [(59.9, "59.9"), (59.99, "59.9"), (0.0, "0.0"), + (99.89, "99.8"), (99.9, "100.0"), (99.99, "100.0"), (100.0, "100.0"), (105.0, "100.0"), (-1.0, "0.0")] { require(compactProgressText(position: position, duration: 100, format: .percentage) == expected, "compact percentage has one decimal and stays bounded: \(expected)") diff --git a/README.md b/README.md index 6317c63..7faafb6 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ automatic_quality = true [ui] buffer_info = true compact_snap_to_edges = true -compact_title_progress = "percentage" # "time", "percentage" (one decimal), or "none" +compact_title_progress = "percentage" # "time", "percentage" (one decimal; 99.9 rounds up to 100.0), or "none" [keys] play = "space" diff --git a/Sources/App/TerebiApp.swift b/Sources/App/TerebiApp.swift index ad988b6..5e3b1cd 100644 --- a/Sources/App/TerebiApp.swift +++ b/Sources/App/TerebiApp.swift @@ -7,6 +7,7 @@ func compactProgressText(position: Double, duration: Double, format: CompactTitl let position = min(max(0, position), duration) if format == .percentage { let tenths = Int((position / duration * 1000).rounded(.down)) + if tenths == 999 { return "100.0" } return "\(tenths / 10).\(tenths % 10)" } let total = Int(min(duration, Double(Int.max / 2)))