Never break up a cell inside a cell that stays in 2D - #2407
Merged
Merged
Conversation
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
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.
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 anddiff()fraction have no linear form and always draw their contents in 2D.CollectWideCells()still descended into them, andBreakUpCells()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, andUnBreakUpCells()(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 inCell::Draw()that a cell drawn in 2D has no broken contents.Tests: new
test_LayoutInvariantsscenario "Nothing inside a subscript is broken into lines" (12 failures onmain, passes now); all 48 unit tests and the Maxima-backed*Cellsbatch tests pass. Checked in the real app: onmainthe 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