Commit 259f022
fix(chunk): keep emoji whole when length-splitting a long line
chunkByNewline length-splits a long line with a raw
`lineValue.slice(0, firstLimit)`, which can cut through a surrogate
pair when firstLimit lands on an odd UTF-16 offset. The first chunk
then ends on a lone high surrogate and the next chunk begins with the
orphaned low surrogate, rendering a broken/replacement glyph.
Guard the boundary with avoidTrailingHighSurrogateBreak (already used by
chunkText/chunkMarkdownText in this file and already imported), so the
split lands on a code-point boundary. Only the rare mid-surrogate
boundary changes; all other inputs are byte-identical.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>1 parent e4763b0 commit 259f022
2 files changed
Lines changed: 19 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
516 | 532 | | |
517 | 533 | | |
518 | 534 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
| 168 | + | |
168 | 169 | | |
169 | | - | |
| 170 | + | |
170 | 171 | | |
171 | 172 | | |
172 | 173 | | |
| |||
0 commit comments