You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 235b1ce
Browse filesBrowse the repository at this point in the historyBrowse files
[web] Respect text affinity in getLineBoundary at a soft wrap (flutter#192664)
Fixesflutter#188874
**Problem**
When text wraps onto a second line, one offset sits in two places at
once: the end of line 1 and the start of line 2. `TextPosition.affinity`
is what says which of the two you mean. Web ignored it.
For `'Test Text'` wrapping after `'Test '`, asking about the start of
line 2:
```
getLineBoundary(TextPosition(offset: 5))
native: TextRange(5, 9) line 2 correct
web: TextRange(0, 5) line 1 wrong
```
Skia reports line bounds inclusively, so line 1's `end` and line 2's
`start` are both 5 and the lookup always matched line 1 first. Line 2
was unreachable from any caret position, which broke line navigation
keys and triple-tap line selection on web. Both shipping web renderers,
CanvasKit and skwasm, had the bug independently.
**Fix**
Ported the lookahead native has used since flutter-team-archive/engine#28008. If the
position is downstream and sits exactly where one line's `end` meets the
next line's `start`, return the next line instead.
Hard line breaks are unaffected, because a newline takes an offset of
its own so the two ranges never touch and the rule cannot fire. A test
pins that.
**Demo**
Before: https://flutter-demo-60-before.web.app
After: https://flutter-demo-60-after.web.app
Repro steps:
1. Click in the text box, then drag the caret so it sits just before the
`A` on the second line. The readout confirms offset 15.
2. The panel underneath follows the caret and shows the range
`getLineBoundary` returns for that position.
3. Before: the caret is drawn on line 2, but the boundary comes back as
`0..15`, which is line 1, so the panel reads MISMATCH.
4. After: the boundary comes back as `15..16` and the panel reads AGREE.
Every other offset behaves identically in both builds. Offset 15 with
downstream affinity is the only input whose answer changes.
0 commit comments