Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Sources/PureMouseKit/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,8 @@ public struct Config: Decodable, Sendable {
if let configured { return configured }
let seconds = systemSeconds.flatMap { $0 > 0 && $0.isFinite ? $0 : nil } ?? 0.5
let range = doubleClickMsRange
return min(max(Int((seconds * 1000).rounded()), range.lowerBound), range.upperBound)
let milliseconds = min(max(seconds * 1000, Double(range.lowerBound)), Double(range.upperBound))
return Int(milliseconds.rounded())
}

public static var defaultURL: URL {
Expand Down
5 changes: 5 additions & 0 deletions Tests/PureMouseKitTests/TriggerTableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,13 @@ import Testing
#expect(fresh.doubleClickInterval(systemSeconds: nil) == 500)
#expect(fresh.doubleClickInterval(systemSeconds: 0.3) == 300)
#expect(fresh.doubleClickInterval(systemSeconds: 5) == 1000)
#expect(fresh.doubleClickInterval(systemSeconds: 1e20) == Config.doubleClickMsRange.upperBound)
#expect(fresh.doubleClickInterval(systemSeconds: Double.greatestFiniteMagnitude) == Config.doubleClickMsRange.upperBound)
#expect(fresh.doubleClickInterval(systemSeconds: 0.05) == 150)
#expect(fresh.doubleClickInterval(systemSeconds: -1) == 500)
#expect(fresh.doubleClickInterval(systemSeconds: .infinity) == 500)
#expect(fresh.doubleClickInterval(systemSeconds: .nan) == 500)
#expect(fresh.doubleClickInterval(systemSeconds: 0.3005) == 301)
#expect(try decode(#"{"doubleClickMs": 250}"#).doubleClickInterval(systemSeconds: 0.8) == 250)
}

Expand Down
Loading