Skip to content

Commit 76b3d23

Browse files
committed
layout: avoid panic due to subtract with overflow
This can occur when 2 Press/Release attached to an HoldTap action are handled between 2 ticks. ``` ERROR panicked at /home/boris/stuff/kb/keyberon/src/layout.rs:319:32: attempt to subtract with overflow ```
1 parent b95e064 commit 76b3d23

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl<T, K> WaitingState<T, K> {
295295
.iter()
296296
.find(|s| self.is_corresponding_release(&s.event))
297297
{
298-
if self.timeout >= self.delay - since {
298+
if since > self.delay || self.timeout >= self.delay - since {
299299
Some(WaitingAction::Tap)
300300
} else {
301301
Some(WaitingAction::Hold)

0 commit comments

Comments
 (0)