Skip to content

Conversation

@chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Aug 26, 2022

Make it public so it can be reused in SelectableRegion

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard
Copy link

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 on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

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

@flutter-dashboard flutter-dashboard bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. labels Aug 26, 2022
@chunhtai chunhtai marked this pull request as draft August 26, 2022 19:10
@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

For more guidance, visit Writing a golden file test for package:flutter.

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

@chunhtai chunhtai marked this pull request as ready for review September 2, 2022 19:34
@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

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

Changes reported for pull request #110367 at sha 6e6d5ef01ff94ae5a46da93388a4c32612404040

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label Sep 2, 2022
@chunhtai chunhtai force-pushed the text-boundary branch 4 times, most recently from ca7dd77 to f696749 Compare September 7, 2022 23:02
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should be in the ui.text, putting it here just for now, will spawn another pr and remove this before merge

Copy link
Contributor Author

Choose a reason for hiding this comment

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

previous test is testing the implementation detail of textOffsetToPosition

Copy link
Contributor

Choose a reason for hiding this comment

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

The original logic here was flawed I think? The visual end of the paragraph may not be the logical end of the paragraph (when the last run in the paragraph has a different directionality from that of the paragraph)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

directionality should be fine as the skia should handle that for us? The problem I facing here is I can't differentiate whether user taps the upstream of the end of the text or far away to the right from the end of the text. I think the correct behavior is we should still select word for the former and collapse at the end for the latter.

Since we can't tell it with the current API, I made it always collapse at the end, since that is what the original behavior is

Copy link
Contributor

Choose a reason for hiding this comment

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

This doc line may need to be changed now it's public

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is really nothing else i can explain in this constructor.

Copy link
Contributor

Choose a reason for hiding this comment

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

points -> points to

Copy link
Contributor

Choose a reason for hiding this comment

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

Some applications don't paint the caret between characters (for instance, in some terminal emulators it's below the character it points to).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure what description i should add here. That will be up to the application to interpret the output?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the offset -1 strategy correct? If there's no bidi text or soft line wraps in a paragraph, then we have

TextPosition(x, downstream) == TextPosition(x, upstream) != TextPosition(x-1, downstream)

right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding of codeUnitboundary is the following. If you have a text 'abc'. To describe the boundary of code unit 'b' will be

leading : TextPosition(offset: 1, affinity:TextAffinity.downStream)
trailing: TextPosition(offset: 2, affinity:TextAffinity.upStream)

The current code should capture this. It make sure any text position that point to 'b' will return that. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah according to what's in TextPainter that looks correct

Copy link
Contributor

@LongCatIsLooong LongCatIsLooong left a comment

Choose a reason for hiding this comment

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

LGTM with nits/questions

Copy link
Contributor

Choose a reason for hiding this comment

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

do we still need this, now that we always treat TextPosition as caret locations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes otherwise you won't be able to move to the next word if the current position is at the edge. This boundary move the position by one affinity. This may need a better name though...

@chunhtai
Copy link
Contributor Author

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 16, 2022
@auto-submit auto-submit bot merged commit bcc1dc6 into flutter:master Sep 16, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 17, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Sep 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems autosubmit Merge PR when tree becomes green via auto submit App framework flutter/packages/flutter repository. See also f: labels. will affect goldens Changes to golden files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants