Skip to content

CommandParser: keep a comma inside a KEY=VALUE argument (#120) - #122

Merged
vv137 merged 1 commit into
mainfrom
fix/120-align-chain-comma
Aug 2, 2026
Merged

CommandParser: keep a comma inside a KEY=VALUE argument (#120)#122
vv137 merged 1 commit into
mainfrom
fix/120-align-chain-comma

Conversation

@vv137

@vv137 vv137 commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Fixes #120.

The bug

:align mob to ref chain=A,B never applied the chain filter.

The command 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 of the argument list, 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

All four documented examples of the chain=A,B,… shorthand (issue #81) were
dead, on :align, :alignto and :loadalign alike.

The fix

No caller could have recovered this: chain=A B and chain=A,B tokenize
identically, 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:

input tokens
rename old, new old · new
color red, obj 1ubq red · obj · 1ubq
set bg rgb(32,32,32) bg · rgb(32 · 32 · 32) (still rejoined by :set)
align m to r chain=A,B m · to · r · chain=A,B

The rgb(R,G,B) path is worth calling out: none of its tokens contain an =,
so it still splits and :set still rejoins it exactly as before.

Verification

  • Added tests/test_command_parser.cpp — the
    tokenizer had no test coverage at all. Pins both halves of the rule, plus
    quoting and rawArgs.
  • chain=A,B now agrees with chain=A+B atom-for-atom; chain1=A,B chain2=A,B
    went from "Target selection empty" to a correct MM alignment.
  • Manually re-checked every comma-dependent command (:rename, :color,
    :show scope forms, :set bg, :set label_color) and the 59-expression
    selection corpus — no change.
  • Full suite green.

Note

Write the list without spaces. chain=A, B is still two arguments and the B
is not part of the filter — documented in the README alongside the shorthand.

🤖 Generated with Claude Code

`: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.
@vv137
vv137 merged commit 2e3955a into main Aug 2, 2026
2 checks passed
@vv137
vv137 deleted the fix/120-align-chain-comma branch August 2, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

:align chain=A,B is dropped — comma-split argv leaks into the target selection

1 participant