Repository navigation
Commit 269f171
committed
[web_paragraph] Fix soft hyphen edge cases
Fix five edge cases in cluster mapping, line layout, and soft-hyphen
wrapping:
1. In _TextClusterMapping.toClusterRange, decrement endClusterIndex when
_clusters[endClusterIndex - 1].start >= end so leading clusterless
code units at offset 0 map to an empty ClusterRange(0, 0) instead of
ClusterRange(0, 1).
2. In TextLayout.extractBidiRuns and TextLayout.addLine, skip empty
clusterRange and bidiLineSpanRange slices produced by standalone
clusterless characters (such as U+200F, U+00AD, or U+200B).
3. In TextLayout.addLine, start contentTextRange and allTextRange at 0
for the first line and at lines.last.hardLineBreakRange.end for
subsequent lines so leading clusterless characters do not leave gaps
in WebParagraph.getLineNumberAt.
4. In _LineBuilder.markSoftLineBreak and consumePendingText, ignore
softHyphen when !hasPendingText so a soft hyphen immediately after
whitespace breaks at the space without reserving hyphen width or
inflating minIntrinsicWidth.
5. In TextLayout.getPositionForOffset, return TextAffinity.upstream when
hit-testing a SoftHyphenBlock so line-boundary and closest-glyph
queries stay on the hyphenated line.
Without this fix, 9 tests in paragraph_edge_cases_test.dart and
paragraph_soft_hyphen_test.dart fail (+73 -7 in felt test).
Assisted-by: Gemini 3.8 Flash (router)1 parent e50f01a commit 269f171
2 files changed
Lines changed: 51 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
224 | | - | |
| 223 | + | |
| 224 | + | |
225 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
226 | 231 | | |
227 | 232 | | |
228 | 233 | | |
| |||
311 | 316 | | |
312 | 317 | | |
313 | 318 | | |
314 | | - | |
315 | | - | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
316 | 329 | | |
317 | 330 | | |
318 | 331 | | |
| |||
461 | 474 | | |
462 | 475 | | |
463 | 476 | | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
464 | 482 | | |
465 | 483 | | |
466 | 484 | | |
| |||
920 | 938 | | |
921 | 939 | | |
922 | 940 | | |
| 941 | + | |
| 942 | + | |
923 | 943 | | |
924 | 944 | | |
925 | 945 | | |
926 | | - | |
| 946 | + | |
927 | 947 | | |
928 | 948 | | |
929 | 949 | | |
| |||
979 | 999 | | |
980 | 1000 | | |
981 | 1001 | | |
982 | | - | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
983 | 1008 | | |
984 | 1009 | | |
985 | 1010 | | |
| |||
1202 | 1227 | | |
1203 | 1228 | | |
1204 | 1229 | | |
1205 | | - | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
1206 | 1237 | | |
1207 | 1238 | | |
1208 | 1239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
319 | 319 | | |
320 | 320 | | |
321 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
322 | 326 | | |
323 | 327 | | |
324 | 328 | | |
325 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
326 | 332 | | |
327 | 333 | | |
328 | 334 | | |
329 | | - | |
| 335 | + | |
330 | 336 | | |
331 | 337 | | |
332 | 338 | | |
| |||
335 | 341 | | |
336 | 342 | | |
337 | 343 | | |
338 | | - | |
| 344 | + | |
339 | 345 | | |
340 | 346 | | |
341 | 347 | | |
| |||
423 | 429 | | |
424 | 430 | | |
425 | 431 | | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | 432 | | |
431 | 433 | | |
432 | 434 | | |
433 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
434 | 440 | | |
435 | 441 | | |
436 | 442 | | |
| |||
0 commit comments