Skip to content

Conversation

@justinmc
Copy link
Contributor

@justinmc justinmc commented Mar 18, 2021

Before this PR, Mac had some incorrect behavior when navigating through text with word modifier keys, as noted in this table: #57679 (comment)

For "word wo|rd| word" selected left to right...

On Mac, pressing word modifier + shift + left should now correctly result in "word wo|rd word". Other platforms result in "word |word| word".

And vice versa for the right arrow and a right to left selection.

Closes #57679
A similar problem in Windows not fixed by this: #78572

@justinmc justinmc self-assigned this Mar 18, 2021
@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Mar 18, 2021
@google-cla google-cla bot added the cla: yes label Mar 18, 2021
//
// See extendSelectionLeftByWord for a detailed explanation of the two
// optional parameters.
static TextSelection _extendGivenSelectionLeftByWord(TextPainter textPainter, TextSelection selection, [bool includeWhitespace = true, bool stopAtReversal = false]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the implementation of _getLeftByWord, I think we may want to change the name to extendGivenSelectionUpstreamByWord or something, as the current implementation moves the extentOffset backwards in the text's logical direction.

const ExtendSelectionLeftByLineTextIntent();
}

/// An [Intent] to extend the selection left past the nearest word, collapsing
Copy link
Contributor

@LongCatIsLooong LongCatIsLooong Mar 19, 2021

Choose a reason for hiding this comment

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

Looks like the method extends the selection towards the start of the text, instead of moving left. Does that match macOS's behavior?

Copy link
Contributor

@LongCatIsLooong LongCatIsLooong Mar 19, 2021

Choose a reason for hiding this comment

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

in Pages in RTL text pressing <- the cursor moves towards the end of the text.

@justinmc
Copy link
Contributor Author

We talked offline about the arrow key direction. The conclusion is that we will fix it in another PR and keep the naming the same for now.

Issue: #78660

It seems that this direction bug existed before I started refactoring text editing shortcuts (tested at 57dc5f2).

@fluttergithubbot fluttergithubbot merged commit 47db96a into flutter:master Mar 22, 2021
@justinmc justinmc deleted the cursor-position-actions branch March 22, 2021 23:25
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.

Add awareness for cursor position in selection-related behaviors across desktop platforms

3 participants