Make a table survive its own source - #161
Open
luca-chen198 wants to merge 2 commits into
Open
Conversation
`.kern` applies to EVERY character in its range, so a run of n characters ends up `width + n * kern` wide. Hiding a run with the run's FULL width therefore overshot by (n - 1) widths. AppKit clamps most such lines to zero, which is why it never showed — until a line held a composed character sequence (`z` + U+0304), which instead laid out at x = +1783 with width -1783 and dragged the container's usage bounds to -1778…695 on a 700pt view. A note whose only content was such a table rendered blank. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Two things a GFM row is allowed to hold that we dropped: `\|` escapes the delimiter, and the escape beats every inline context because rows are split before inline parsing runs. Splitting on the raw character cut such a row short at the header's column count, silently losing the rest of the line. `<br>` is the only in-cell line break the format has, since a row IS one source line. It drew literally, and Return inside a row could only tear the table in half — so Return (and ⇧↵, which AppKit sends as the same `insertNewline:`) now inserts `<br>` instead. The table's outer edges stay a plain newline: that is the only way out of a table sitting at the end of a document. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
One real note surfaced three defects in the same subsystem: it rendered as a completely blank page.
The blank page
The note's only content was a 14-line table, so the whole document collapsed into one hidden source run. A collapsed block hides its raw text by shrinking it to a near-zero font and kerning the rest of its width away — but
.kernapplies to every character in its range, so a run of n characters ends upwidth + n * kernwide. Feeding it the run's FULL width overshot by (n − 1) widths.AppKit clamps most such lines to zero width, which is why this never showed. One line in that note held
z̄— azplus U+0304 — and that line did not clamp: it laid out at x = +1783 with width −1783, draggingusageBoundsForTextContainerto −1778…695 on a 700pt container.Measured, one variable at a time:
(-1778.2, 0, 2473.2, 655.5)(5.0, 0, 690.0, 655.5)(5.0, 0, 690.0, 673.5)Two more the same note found
\|truncated its row. GFM escapes the delimiter, and the escape beats every inline context because rows are split before inline parsing runs — so`Var[x(1) \| z(1:3)]`is one cell. Splitting on the raw character cut the row short at the header's column count and silently dropped the rest of the line.<br>had no meaning. It is the only in-cell line break the format has (a row is one source line), and it drew literally. Return inside a row could therefore only tear the table in half.Return in a table
Return — and ⇧↵, which AppKit sends as the same
insertNewline:— now inserts<br>instead of splitting the row. The table's outer edges deliberately stay a plain newline: that is the only way out of a table sitting at the end of a document.Tests
7 new tests across
TableHiddenSourceGeometryTestsandTableCellSourceTests; each was confirmed red against the unfixed sources. Full suite: 454 passing.🤖 Generated with Claude Code