fix: round final compact progress fraction to completion
This commit is contained in:
@@ -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)")
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user