CommandParser: keep a comma inside a KEY=VALUE argument (#120) - #122
Merged
Conversation
`:align mob to ref chain=A,B` never applied the chain filter. The tokenizer
treats `,` as an argument separator identical to whitespace, so the modifier
arrived as `chain=A` plus an orphaned `B`. popModeToken pops recognised
modifiers off the back, hit the bare `B` first, and stopped — leaving chain1/
chain2 unset and the remnants to leak into the target selection:
:align 1ubq to 1brs chain1=A,B chain2=A,B
Target selection empty: chain1=A B chain2=A B
Four documented examples of the `chain=A,B,…` shorthand (issue #81) were dead,
on `:align`, `:alignto` and `:loadalign` alike.
No caller could have recovered: `chain=A B` and `chain=A,B` tokenize
identically, so the information is gone before the command sees it. Fixed
where it is lost — a comma inside an argument that already contains `=`
belongs to the value. Bare commas keep separating, so `:rename old, new`,
`:color red, obj 1ubq` and the `rgb(32,32,32)` rejoin path are untouched.
Adds tests/test_command_parser.cpp, which had no coverage at all, pinning both
halves of the rule.
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.
Fixes #120.
The bug
:align mob to ref chain=A,Bnever applied the chain filter.The command tokenizer treats
,as an argument separator identical towhitespace, so the modifier arrived as
chain=Aplus an orphanedB.popModeTokenpops recognised modifiers off the back of the argument list, hitthe bare
Bfirst, and stopped — leavingchain1/chain2unset and theremnants to leak into the target selection:
All four documented examples of the
chain=A,B,…shorthand (issue #81) weredead, on
:align,:aligntoand:loadalignalike.The fix
No caller could have recovered this:
chain=A Bandchain=A,Btokenizeidentically, so the information is gone before the command ever sees it. Fixed
where it is lost — a comma inside an argument that already contains
=belongs to the value.
Bare commas keep separating, so the PyMOL-style forms are untouched:
rename old, newold·newcolor red, obj 1ubqred·obj·1ubqset bg rgb(32,32,32)bg·rgb(32·32·32)(still rejoined by:set)align m to r chain=A,Bm·to·r·chain=A,BThe
rgb(R,G,B)path is worth calling out: none of its tokens contain an=,so it still splits and
:setstill rejoins it exactly as before.Verification
tokenizer had no test coverage at all. Pins both halves of the rule, plus
quoting and
rawArgs.chain=A,Bnow agrees withchain=A+Batom-for-atom;chain1=A,B chain2=A,Bwent from "Target selection empty" to a correct MM alignment.
:rename,:color,:showscope forms,:set bg,:set label_color) and the 59-expressionselection corpus — no change.
Note
Write the list without spaces.
chain=A, Bis still two arguments and theBis not part of the filter — documented in the README alongside the shorthand.
🤖 Generated with Claude Code