-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
TextSelection has a single affinity property, and according to its docs, it only applies when collapsed:
If the text range is collapsed and has more than one visual location (e.g., occurs at a line break), which of the two locations to use when painting the caret.
I think that this may be an oversight and a source of bugs, especially when using a keyboard. For example, these selections are different, but Flutter has no way to distinguish between the two:
| extent TextAffinity.downstream | extent TextAffinity.upstream | Flutter treats them both as: |
|---|---|---|
This text wra|ps because it's |too long. |
This text wra|ps because it's | too long. |
![]() |
Why does it matter?
When using keyboard shortcuts that jump to the beginning/end of a line, it's important to know what line the base and extent are on. Consider doing cmd-shift-right (expand to end of line) in my example in the table above. If the extent is upstream, the selection shouldn't change. If it's downstream, it should select to the end fo the field. Always assuming one or the other affinity won't always make sense.
Related
https://github.com/flutter/flutter/pull/87973/files#r685632915
#85653
