fix(REN-3): \color and \colorbox atoms now receive inter-element spacing#231
fix(REN-3): \color and \colorbox atoms now receive inter-element spacing#231kostub wants to merge 2 commits into
Conversation
Before this fix, `kMTMathAtomColor` and `kMTMathAtomColorbox` cases in
`-createDisplayAtoms:` never called `addInterElementSpace:prevNode
currentType:atom.type`, so a colored group lost its leading inter-element
gap. For example, the medium binary-operator space in `x+\color{red}y`
was dropped, causing the colored `y` to abut the `+` with no gap.
The fix adds the missing `addInterElementSpace:` call to each case (after
the line flush, before `display.position = _currentPosition`), mirroring
the text-case and inner-case patterns. Both atom types already map to index
0 (Ordinary) in `getInterElementSpaceArrayIndexForType`, so no table
changes are needed.
Three new typesetter tests cover:
- `\color` before a binary operator gap (RED → GREEN)
- `\colorbox` before a binary operator gap (RED → GREEN)
- regression guard that spacing after a `\color` group is preserved (already GREEN)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request adds inter-element spacing before color and colorbox atoms in MTTypesetter.m to ensure they are spaced correctly as ordinary atoms (e.g., leaving a medium gap after a binary operator). It also adds comprehensive unit tests in MTTypesetterTest.m to verify this spacing behavior and ensure that spacing after color groups remains preserved. There are no review comments to address, and I have no additional feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
EM-REVIEW v1 Verdict: Approve-equivalent (not approving per instructions). Blocking issues: none. Reviewed the REN-3 fix: adds 1. Call placement — correct. Placed after the 2. Spacing resolution — correct. 3. No double-spacing / off-by-one. The color case flushes 4. Test expectation — correct and robust. 5. No regression to non-color atoms. Change is confined to the two color cases; all other cases untouched. The post-color side already worked via the standard table path and is now guarded by Minor (non-blocking):
No blocking issues. The +2 functional lines are minimal, correctly placed, and the spacing derivation is sound on both sides of the color group. 🤖 Generated with Claude Code |
Addresses non-blocking review nit. The previous comment block re-derived the Ord->BinOp spacing three times with a self-contradicting "But because" pivot. Replaced with one accurate sentence. No behavioral change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Addressed the non-blocking nit in f40c063: trimmed the rambling/self-contradicting comment in |
Summary
kMTMathAtomColorandkMTMathAtomColorboxcases in-createDisplayAtoms:never calledaddInterElementSpace:, so colored groups lost their leading inter-element gap (e.g. the medium binary-operator space inx+\color{red}ywas dropped, causingyto abut+with no gap).[self addInterElementSpace:prevNode currentType:atom.type]call per case, after the line flush and beforedisplay.position = _currentPosition, mirroring the existing text-case and inner-case patterns. Both atom types already map to Ordinary (index 0) ingetInterElementSpaceArrayIndexForType, so no spacing-table changes are required. Net change: +2 lines inMTTypesetter.m.MTTypesetterTest:\colorbefore binary-op gap (was RED, now GREEN),\colorboxbefore binary-op gap (was RED, now GREEN), regression guard that spacing after a\colorgroup is preserved (was already GREEN).Closes REN-3 from issues.md.
Test plan
swift buildpasses with no warningsswift testpasses all 295 tests (89 inMTTypesetterTest, 3 new)testColorReceivesInterElementSpacingBeforeIt— asserts the medium binary-op gap (4 mu = 4 × muUnit) before\colortestColorboxReceivesInterElementSpacingBeforeIt— same for\colorboxtestSpacingAfterColorGroupIsPreserved— regression guard that the already-working post-color spacing still holds🤖 Generated with Claude Code