Skip to content

Fix cursor moving to next line instead of end of line - #87133

Merged
fluttergithubbot merged 2 commits into
flutter:masterfrom
justinmc:move-by-line-affinity
Jul 29, 2021
Merged

fluttergithubbot merged 2 commits into
flutter:masterfrom
justinmc:move-by-line-affinity

Conversation

@justinmc

@justinmc justinmc commented Jul 27, 2021 •

Copy link
Copy Markdown
Contributor

Previously, when doing cmd + right arrow, the cursor incorrectly went to the start of the next line instead of the end of the current line due to a TextAffinity problem.

Say the selection is somewhere in a line:

Screen Shot 2021-07-27 at 1 15 43 PM

The user then hits cmd-right, which should move the cursor to the end of the current line, but currently the affinity gets lost and it goes to the next line:

Screen Shot 2021-07-27 at 1 16 07 PM

After this PR, it correctly goes to the end of the line:

Screen Shot 2021-07-27 at 1 15 52 PM

This PR also explicitly sets the affinity in the left direction, even though it's the same as the default.

@justinmc
justinmc requested a review from Renzo-Olivares July 27, 2021 20:20
@justinmc justinmc self-assigned this Jul 27, 2021
@google-cla google-cla Bot added the cla: yes label Jul 27, 2021
@flutter-dashboard flutter-dashboard Bot added the framework flutter/packages/flutter repository. See also f: labels. label Jul 27, 2021

@Renzo-Olivares Renzo-Olivares left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can this be tested? Maybe by checking the cursor position before/after executing the shortcut (if that's possible).

LGTM other than that

@justinmc

Copy link
Copy Markdown
Contributor Author

@Renzo-Olivares The changes I made in the test files do just that. The existing tests executed the shortcut and then checked the position just using base/extentOffset, but that wasn't enough, they also needed to check affinity, which is what I added.

For example: https://github.com/flutter/flutter/pull/87133/files#diff-c1cc83e1184249de6aacb50fcdbb3c1eb4e98b9d5b1947c9b375c247818ea5d9L882-R885

@Renzo-Olivares Renzo-Olivares left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM thank you for clarifying on the test.

@fluttergithubbot
fluttergithubbot merged commit c5866c5 into flutter:master Jul 29, 2021
@justinmc
justinmc deleted the move-by-line-affinity branch July 30, 2021 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants