Skip to content

Commit

Permalink
layout: avoid panic due to subtract with overflow
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
borisfaure committed Jan 6, 2025
1 parent d6f87ad commit 8cee9a0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl<T, K> WaitingState<T, K> {
.iter()
.find(|s| self.is_corresponding_release(&s.event))
{
if self.timeout >= self.delay - since {
if self.timeout + since >= self.delay {
Some(WaitingAction::Tap)
} else {
Some(WaitingAction::Hold)
Expand Down

0 comments on commit 8cee9a0

Please sign in to comment.