Skip to content

Never break up a cell inside a cell that stays in 2D - #2407

Merged
gunterkoenigsmann merged 2 commits into
mainfrom
claude/fix-layout-fontsize-mismatch
Sep 29, 2026
Merged

gunterkoenigsmann merged 2 commits into
mainfrom
claude/fix-layout-fontsize-mismatch

Conversation

@gunterkoenigsmann

Copy link
Copy Markdown
Member

Requested by Gunter · project thread

Before: a wide fraction or parenthesis inside a subscript (e.g. a[(x_1+...)/(y_2+...)] in a narrow window) was partly broken into lines or vanished entirely, and stayed that way after the window was widened again.

After: everything inside a subscript stays in 2D, like the subscript itself.

A subscript, SubSupCell, at(), matrix and diff() fraction have no linear form and always draw their contents in 2D. CollectWideCells() still descended into them, and BreakUpCells() linearized the wide cells it found there. Only a cell that is itself broken into lines hands its contents to the draw list, so those cells were positioned and drawn by nobody, and UnBreakUpCells() (which walks that same draw list) never returned them to 2D.

How: CollectWideCells() now records, for each wide cell, the wide cell it was found in, and only searches the contents of cells it collected itself; BreakUpCells() skips a cell whose containing wide cell didn't actually break up. No extra tree walks, so no layout slowdown. Debug builds additionally assert in Cell::Draw() that a cell drawn in 2D has no broken contents.

Tests: new test_LayoutInvariants scenario "Nothing inside a subscript is broken into lines" (12 failures on main, passes now); all 48 unit tests and the Maxima-backed *Cells batch tests pass. Checked in the real app: on main the subscript's fraction is not drawn at all; with this change it is drawn in 2D. Also updated NEWS.md, AGENTS.md and the layout skill (new invariant 5).

🤖 Generated with Claude Code

https://claude.ai/code/session_01V5Yz1a2PmuAUtJ7zYKsmuX


Generated by Claude Code

A subscript (and a matrix, an at(), a diff() fraction) has no linear
form, so it is always drawn in 2D. CollectWideCells() still descended
into it and BreakUpCells() linearized the wide fractions and parentheses
inside it. Only a cell that is itself broken into lines hands its
contents to the draw list, so those cells were positioned and drawn by
nobody (a wide subscript simply vanished), were only partly visible, and
UnBreakUpCells(), walking the same draw list, never returned them to 2D.

CollectWideCells() now only searches the contents of a cell it collected
itself and records which wide cell each one was found in, and
BreakUpCells() skips a cell whose containing wide cell did not actually
break up. Debug builds assert the invariant in Cell::Draw().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V5Yz1a2PmuAUtJ7zYKsmuX
@gunterkoenigsmann gunterkoenigsmann self-assigned this Sep 29, 2026
@gunterkoenigsmann
gunterkoenigsmann merged commit c1221da into main Sep 29, 2026
0 of 20 checks passed
@gunterkoenigsmann
gunterkoenigsmann deleted the claude/fix-layout-fontsize-mismatch branch September 29, 2026 19:43
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.

2 participants