fix: preserve streamed line starts inside a chunk#129
Draft
lttlin wants to merge 1 commit intochenglou:mainfrom
Draft
fix: preserve streamed line starts inside a chunk#129lttlin wants to merge 1 commit intochenglou:mainfrom
lttlin wants to merge 1 commit intochenglou:mainfrom
Conversation
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.
Problem
layoutNextLine()andlayoutNextLineRange()renormalize every continuation cursor as if it were starting from a fresh paragraph or chunk boundary. In mixed-script edge cases with aZWSPbreak opportunity followed by collapsible whitespace, that can skip a real continuation segment and merge two streamed lines thatlayoutWithLines()keeps separate.Root Cause
The line-start normalization helpers unconditionally skipped
space,zero-width-break, andsoft-hyphensegments even when the caller was resuming from an exactendcursor returned by the previous streamed line. That normalization is correct at the true start of a paragraph or chunk, but it is too aggressive for continuation cursors inside an existing chunk.Fix
Only trim collapsible leading break-opportunity segments when the cursor is at the true paragraph start or chunk start. If the caller resumes from a later in-chunk cursor, preserve it exactly and continue streaming from that segment.
Validation
cd /tmp/pretext_issue_121 && ~/.bun/bin/bun test src/layout.test.ts --test-name-pattern 'streaming canary preserves exact continuation cursors after a ZWSP break opportunity|layoutWithLines strips leading collapsible space after a ZWSP break the same way as layoutNextLine|layoutNextLine reproduces layoutWithLines exactly'cd /tmp/pretext_issue_121 && ~/.bun/bin/bun test src/layout.test.tsCloses #121