Skip to content

Commit

Permalink
fix(macro): keep macro states on macro completion (#1243)
Browse files Browse the repository at this point in the history
Fixes #1199, kinda. Macro no longer consumes other macro outputs but
doesn't fix the exact described use case in the GitHub issue.

A bug is fixed at least.
  • Loading branch information
jtroo authored Sep 22, 2024
1 parent f3e6b7f commit 0e69814
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
5 changes: 0 additions & 5 deletions keyberon/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1354,11 +1354,6 @@ impl<'a, const C: usize, const R: usize, T: 'a + Copy + std::fmt::Debug> Layout<
// Process it (SequenceEvent)
match seq.cur_event {
Some(SequenceEvent::Complete) => {
for fake_key in self.states.clone().iter() {
if let FakeKey { keycode } = *fake_key {
self.states.retain(|s| s.seq_release(keycode).is_some());
}
}
seq.remaining_events = &[];
}
Some(SequenceEvent::Press(keycode)) => {
Expand Down
26 changes: 26 additions & 0 deletions src/tests/sim_tests/chord_sim_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,29 @@ fn sim_chord_release_nonchord_key_has_correct_order() {
result
);
}

#[test]
fn sim_chord_simultaneous_macro() {
let result = simulate(
"
(defsrc a b o)
(deflayer default
(chord base a)
(chord base b)
(chord base o)
)
(defchords base 500
(a) (macro a z)
(b) (macro b)
(o) o
(a o) o
)
",
"d:a t:10 d:b t:500",
)
.to_ascii();
assert_eq!(
"t:502ms dn:A dn:B t:1ms up:A up:B t:1ms dn:Z t:1ms up:Z",
result
);
}

0 comments on commit 0e69814

Please sign in to comment.