fix: chain action ignores underscores in command names and mouse-button binds#7952
Merged
Merged
Conversation
Collaborator
|
I would prefer a separate PR to check other cases where p->pt is appropriate (vs spot-checked PRs for each such case). If you think the scope fits in a single PR, though, that's fine. Otherwise looks good at a glance. |
Member
|
@Arcadiyyyyyyyy Have you had a chance to address the feedback? |
Contributor
Author
Unfortunately, not yet, I will try my best to look into it this week |
6 tasks
Contributor
Author
Addressed the feedback in #8168 |
WatchTheFort
requested changes
Jul 8, 2026
Revert p -> pt change, left for separate PR
WatchTheFort
approved these changes
Jul 8, 2026
Contributor
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.
Work done
Two independent bugs in
luaui/Widgets/cmd_chainactions.luaprevented thechainaction from working with a large class of commands and from working at all on mouse-button binds. Both are fixed; each is described separately below.Fix 1 —
chainbreaks on command names containing underscoresProblem
Each chained sub-command is parsed with:
Lua's
%wmatches[A-Za-z0-9]and excludes_, so the command name is truncated at the first underscore. Any action whose name contains_(e.g.set_camera_anchor,focus_camera_anchor, and most Lua-registered actions) is parsed as a wrong command plus leftover text:The truncated name (
set,focus) is never present inactionHandler'skeyPressActions, soactionHandler:KeyActionreturnsfalse. The sub-command can then only reach the engine through theSpring.SendCommandsfallback (which re-tokenizes the full line correctly), andtryRawCmdreturnsfalse.Consequences
forcemode: the chain usestryRawCmd's return value as the "did the first command respond" gate. An underscored action returnsfalse(it only ran via theSendCommandsfallback), so the chain executes the first sub-command but then aborts and silently drops every sub-command after it.forcemode: the gate is skipped, so every sub-command is attempted — but underscored Lua actions still only reach the engine via theSendCommandstext fallback. Soforceis only a partial workaround: it works exclusively for actions that have text-command support ('t'), it never restores properKeyActiondispatch, and it does nothing about the underlying parse bug.Repro
Fix
Capture the command as the first whitespace-delimited token, matching how the engine (and
actionHandler:TextAction) tokenizes action lines:After this,
cmd="set_camera_anchor"matches the action registered inkeyPressActions,KeyActionreturnstrue, and the chain proceeds through the proper dispatch path with no need forforce.Verified against the existing chain examples (
select PrevSelection++_ClearSelection_SelectPart_50+,group unset,buildfacing inc): output is byte-for-byte identical with the old pattern. The only command names whose parsing changes are those that themselves contain an underscore — they are now captured in full instead of being truncated at the first_. (Underscores inside the argument part, e.g. inside aselect …filter, were always inextraand are unaffected.)Fix 2 —
chaincannot be triggered from a mouse-button bindProblem
The action is registered press-only:
In Recoil the two input sources reach widget actions through different dispatch sets in
actions.lua:actionHandler:KeyAction→ looked up inkeyPressActions(the'p'set).actionHandler:TextAction→ looked up intextActions(the't'set).Because
chainis registered as'p'only, it exists inkeyPressActionsbut not intextActions. A keyboard bind (sc_insert) finds it; a mouse-button bind (mouse5) does not, and the press is silently dropped. This is also why a directbind mouse5 set_camera_anchor …always worked:set_camera_anchor/focus_camera_anchorare registered'pt', so they are reachable from both paths.Fix
Register
chainfor both press and text:chainHandlerneeds no change: the two paths hand it equivalent arguments.KeyActioncallsTryAction(set, cmd, extra, split(extra), …)andTextActioncallsTryAction(textActions, cmd, line, split(line), …), where in both cases the command word (chain) has already been stripped, sochainHandlerreceives the sameextra(everything afterchain) and the samebOpts(bOpts[1] == "force").forcedetection, the|split, and per-segment dispatch are therefore identical on both paths. Keyboard behaviour is unchanged (keyboard still uses the press path only — no double dispatch).Repro
How to test
Setup:
uikeys.txt, then reload them (restart the match, or reload hotkeys). Thechainwidget ("Chain Actions") is enabled by default; confirm it is loaded in the F11 widget list.Camera anchor set: N(fromset_camera_anchor) and forsayoutput, or tailinfolog.txt.Checklist:
force, underscored (Fix 1):bind sc_insert chain set_camera_anchor 4 | focus_camera_anchor 4— pressing Insert sets anchor 4 and focuses it. Before the fix the second action never fired.force(Fix 2):bind mouse5 chain force set_camera_anchor 4 | say chain ok— pressing mouse5 printsCamera anchor set: 4andchain ok. Before the fix nothing happened.force, underscored (Fix 1 + Fix 2):bind mouse4 chain set_camera_anchor 2 | focus_camera_anchor 2— pressing mouse4 runs both actions.forcestill works:bind Alt+f chain force forcestart | say hi.selectwith underscores unaffected:bind Ctrl+tab select AllMap+_Builder_Idle+_ClearSelection_SelectOne+.AI / LLM usage statement
The change was written by Claude (Opus 4.8); my contribution was identifying the bugs and validating the fixes.