From d6f87ad2ff438559b99bad10a1aabdf87914aa94 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Sun, 22 Dec 2024 15:38:11 +0100 Subject: [PATCH] layout: add test reproducing a panic --- src/layout.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/layout.rs b/src/layout.rs index 19593af..c4929a5 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -960,6 +960,29 @@ mod test { assert_keys(&[], layout.keycodes()); } + #[test] + fn stacked_hold_tap() { + static LAYERS: Layers<2, 1, 1> = [[[ + k(Enter), + HoldTap(&HoldTapAction { + timeout: 10, + hold: k(LAlt), + tap: k(Space), + config: HoldTapConfig::Default, + tap_hold_interval: 0, + }), + ]]]; + + let mut layout = Layout::new(&LAYERS); + assert_eq!(CustomEvent::NoEvent, layout.tick()); + // Push 2 events in a row, without ticking: + // Press/Release attached to a HoldTap + layout.event(Press(0, 1)); + layout.event(Release(0, 1)); + assert_eq!(CustomEvent::NoEvent, layout.tick()); + assert_eq!(CustomEvent::NoEvent, layout.tick()); + } + #[test] fn multiple_actions() { static LAYERS: Layers<2, 1, 2> = [