fix(behaviors): Correct macro release state for parametrized macros#2942
Merged
petejohanson merged 2 commits intozmkfirmware:mainfrom Jul 29, 2025
Merged
fix(behaviors): Correct macro release state for parametrized macros#2942petejohanson merged 2 commits intozmkfirmware:mainfrom
petejohanson merged 2 commits intozmkfirmware:mainfrom
Conversation
2f71d6b to
8c25f7c
Compare
Contributor
|
Nice spot. It feels a bit weird to me to apply a fix to every behaviour, though it could be argued that a refactor should happen to treat each behaviour individually. Shouldn't this sort of reset happen after the wait for release? |
nmunnich
approved these changes
May 15, 2025
Contributor
nmunnich
left a comment
There was a problem hiding this comment.
After a brief discussion on Discord I am now convinced.
8c25f7c to
9779b2c
Compare
Contributor
Author
|
I expect this might also fix #2031, but would need testing to confirm. |
petejohanson
approved these changes
Jul 29, 2025
Contributor
petejohanson
left a comment
There was a problem hiding this comment.
Good catch, and thanks for the additional test!
jrsharp
pushed a commit
to jrsharp/zmk
that referenced
this pull request
Nov 4, 2025
…mkfirmware#2942) test(behaviors): Add parametrized macro test that fails fix(behaviors): Correct macro release state for parametrized
drewlwhitney
pushed a commit
to drewlwhitney/zmk
that referenced
this pull request
Dec 22, 2025
…mkfirmware#2942) test(behaviors): Add parametrized macro test that fails fix(behaviors): Correct macro release state for parametrized
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a test for a macro bug where parameter passing isn't working correctly after
¯o_pause_for_release, and proposes a fix.The root cause seems to be that when pre-computing release state in
behavior_macro_init, the parameter passing logic of the on-press portion is only partially taken into account. That is, control bindings like¯o_param_1to1are properly consumed (through thehandle_control_bindingcalls) but whether the parameters are then used by a non-control behavior isn't considered: the release state precomputation does not replicate the resetting ofparam*_sourcevariables that happens withinreplace_paramsduring the on-press portion of the bindings. So the fix is to do this reset whenever a non-control behavior is encountered, emulating thereplace_paramscall insidequeue_macro.As an example, in the added test,
&kp MACRO_PLACEHOLDERconsumes the previous¯o_param_1to1directive, both before¯o_pause_for_release. But&mo 1that comes after the release still uses the first parameter because the release state precomputation didn't apply theparam*_sourceresetting logic.Fixes #2921.
PR check-list