Skip to content

Conversation

@GaryQian
Copy link
Contributor

@GaryQian GaryQian commented Nov 12, 2019

Fixes #40095

When affinity is unknown, we pass null instead of defaulting to TextAffnity.downstream. This allows us to supply fallback affinities computed from libtxt.

Since LibTxt tracks affinities in the getPositionForOffset call (used in renderEditable in selectPositionAt and selectWordEdge), we can use the affinity information by falling back to libtxt affinity when the platform provided affinity is null.

This also exposes getLineBoundary in TextPainter, which is then used to choose the LibTxt affinity when at the end of the line since selections at the end of lines cannot be downstream affinity without jumping to the next line.

@fluttergithubbot fluttergithubbot added the framework flutter/packages/flutter repository. See also f: labels. label Nov 12, 2019
@fluttergithubbot
Copy link
Contributor

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@GaryQian
Copy link
Contributor Author

Will attempt to do this without the addition of ambiguous

@GaryQian GaryQian changed the title Track fallback TextAffinity and use ambiguous affinity by default for platform selections. Track and use fallback TextAffinity for null affinity platform TextSelections. Nov 12, 2019
@GaryQian
Copy link
Contributor Author

This version makes use of null instead of the explicit "ambiguous" affinity. This adds no additional API, and is no longer dependent on flutter/engine#13787

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good and makes sense to me, but did you verify that it fixes the problem in the issue? I still get the problem when I try it. Maybe I'm doing something else though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be more robust to use value.copyWith here, or did you purposely avoid it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh you are right, should just use this.

@GaryQian
Copy link
Contributor Author

Wait it was working in my repro, let me try some more cases.

@GaryQian
Copy link
Contributor Author

@justinmc are you sure you are running the parched version? Mine seems to work with a variety of TextFields and settings on multiple devices.

Do you mind posting the code you are using?

@justinmc
Copy link
Contributor

There is no engine piece needed now, right? I just checked out your branch and ran a plain app with a multiline TextField.

@justinmc
Copy link
Contributor

I'm trying it again and will post my code in a second.

@GaryQian
Copy link
Contributor Author

Oh wait this may not work for iOS that's what it probably is

@GaryQian
Copy link
Contributor Author

This specifically addresses the fact that android does not pass an affinity. Have not seen what iOS does.

@GaryQian
Copy link
Contributor Author

Give me a second and I'll look at the iOS side of it

@justinmc
Copy link
Contributor

Ohh that makes sense. Sounds good.

@GaryQian
Copy link
Contributor Author

@justinmc Should be ready for another round. This version is a bit cleaner and fixes the bug on iOS in conjunction with flutter/engine#13852

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid "we" statements in comments. They're confusing to non-native speakers and require extra thought to understand who "we" is referring to. (And they don't really add any information anyhow)

Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

@GaryQian GaryQian merged commit 6b66d79 into flutter:master Nov 21, 2019
GaryQian added a commit that referenced this pull request Nov 27, 2019
GaryQian added a commit that referenced this pull request Nov 28, 2019
tvolkert added a commit that referenced this pull request Jan 27, 2020
* flutter/engine@a677925 Cherry pick infra testing updates into hotfixes
* flutter/engine@b1bb773 Raise API level for reportFullyDrawn
* flutter/engine@a433ed9 v1.12.13+hotfix.7 cherry-picks
  * google/skia@a640745 Disable QCOM_tiled_rendering while we wait for test devices
  * flutter/engine@bcb8267 Revert "Do not default to downstream affinity on iOS insertText"
* d345a3b Revert "Track and use fallback TextAffinity for null affinity platform TextSelections. (#44622)"
* bd25f70 Upgrade dartdoc to 0.29.3
* 7915e58 Change firebase Pixel3 version from Q-beta3 to 29
justinmc pushed a commit to justinmc/flutter that referenced this pull request Apr 8, 2020
responilla07 pushed a commit to responilla07/flutter that referenced this pull request Jun 8, 2020
* flutter/engine@a677925 Cherry pick infra testing updates into hotfixes
* flutter/engine@b1bb773 Raise API level for reportFullyDrawn
* flutter/engine@a433ed9 v1.12.13+hotfix.7 cherry-picks
  * google/skia@a640745 Disable QCOM_tiled_rendering while we wait for test devices
  * flutter/engine@bcb8267 Revert "Do not default to downstream affinity on iOS insertText"
* d345a3b Revert "Track and use fallback TextAffinity for null affinity platform TextSelections. (flutter#44622)"
* bd25f70 Upgrade dartdoc to 0.29.3
* 7915e58 Change firebase Pixel3 version from Q-beta3 to 29
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiline TextField does't render trailing spaces on prev lines: Affinity bug.

5 participants