fix: preserve streamed line starts inside a chunk#129
Closed
lttlin wants to merge 1 commit intochenglou:mainfrom
Closed
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
Owner
|
Thanks! I've implement this and credited you as co-author |
chenglou
added a commit
that referenced
this pull request
Apr 18, 2026
Normalize chunked batch line starts through the same segment-kind policy used by streaming so layoutWithLines(), walkLineRanges(), layoutNextLine(), and layout() stay aligned after zero-width break opportunities and collapsible spaces. Classify Hangul Compatibility Jamo (U+3130..U+318F) as CJK so common Korean compatibility jamo runs break like browser text. Refs #129, #135, #141. Closes #121 Closes #142 Co-authored-by: mayrang <pkss0626@naver.com> Co-authored-by: voidborne-d <voidborne-d@users.noreply.github.com> Co-authored-by: lttlin <lttlin@gmail.com>
nice-hang
pushed a commit
to nice-hang/pretext
that referenced
this pull request
Apr 18, 2026
Normalize chunked batch line starts through the same segment-kind policy used by streaming so layoutWithLines(), walkLineRanges(), layoutNextLine(), and layout() stay aligned after zero-width break opportunities and collapsible spaces. Classify Hangul Compatibility Jamo (U+3130..U+318F) as CJK so common Korean compatibility jamo runs break like browser text. Refs chenglou#129, chenglou#135, chenglou#141. Closes chenglou#121 Closes chenglou#142 Co-authored-by: mayrang <pkss0626@naver.com> Co-authored-by: voidborne-d <voidborne-d@users.noreply.github.com> Co-authored-by: lttlin <lttlin@gmail.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.
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