-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Mac cmd + shift + left/right #95948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mac cmd + shift + left/right #95948
Conversation
2f10e2e to
5136086
Compare
|
|
||
| const SingleActivator(LogicalKeyboardKey.arrowLeft, shift: true, meta: true): const ExtendSelectionToLineBreakIntent(forward: false, collapseSelection: false), | ||
| const SingleActivator(LogicalKeyboardKey.arrowRight, shift: true, meta: true): const ExtendSelectionToLineBreakIntent(forward: true, collapseSelection: false), | ||
| const SingleActivator(LogicalKeyboardKey.arrowLeft, shift: true, meta: true): const ExtendSelectionToLineBreakIntent(forward: false, collapseSelection: false, expand: true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LongCatIsLooong What do you think of adding this expand parameter here, or would it be better to do something like creating an all new intent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable, but I would slightly prefer having a different intent since collapseSelection and expand can't both be true and currently it relies on a run time assert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've created a new Intent as a subclass of DirectionalTextEditingIntent and I think it worked out cleaner 👍 .
LongCatIsLooong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nits
| } | ||
|
|
||
| final TextPosition extent = textBoundarySelection.extent; | ||
| late final TextPosition position; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: is the late needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undone with refactoring to use a new Intent.
| /// be held in place while the extent is moved. | ||
| /// | ||
| /// When set to true, the selection will expand, meaning that the selection | ||
| /// will grow by moving either the base or the extent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"whichever is closest to the target location" or something similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also maybe say this is typically only for macOS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exact comment was removed because I created a separate Intent. I made sure that Intent's comments were clear and I added a line about MacOS there.
| final TextSelection newSelection = collapseSelection | ||
| ? TextSelection.fromPosition(newExtent) | ||
| : textBoundarySelection.extendTo(newExtent); | ||
| late final TextSelection newSelection; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary late?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undone with refactoring to use a new Intent.
| if (collapseSelection) { | ||
| newSelection = TextSelection.fromPosition(newExtent); | ||
| } else { | ||
| newSelection = intent.expand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this and it seems macos does not move the extent when it expands the selection? cmd+shift+-> and then press -> the cursor moves to 1 character to the right from its original position.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've got this right now, the behavior might have changed since you tested it. Here's what I'm testing that seems to match with TextEdit:
- With cursor in the middle of the line, cmd + left. Left end is the extent.
- With cursor in the middle of the line, cmd + right. Right end is the extent.
- With cursor in the middle of the line, cmd + left then cmd + right. Left end is the extent.
- With cursor in the middle of the line, cmd + right then cmd + left. Right end is the extent.
- With an RTL selection in the middle of the line, cmd + left. Left end is the extent.
- With an RTL selection in the middle of the line, cmd + right. Left end is the extent.
- With an LTR selection in the middle of the line, cmd + right. Right end is the extent.
- With an LTR selection in the middle of the line, cmd + left. Right end is the extent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added tests for all of these cases too. By "testing" in the previous comment I meant manually trying myself vs. TextEdit.
|
|
||
| const SingleActivator(LogicalKeyboardKey.arrowLeft, shift: true, meta: true): const ExtendSelectionToLineBreakIntent(forward: false, collapseSelection: false), | ||
| const SingleActivator(LogicalKeyboardKey.arrowRight, shift: true, meta: true): const ExtendSelectionToLineBreakIntent(forward: true, collapseSelection: false), | ||
| const SingleActivator(LogicalKeyboardKey.arrowLeft, shift: true, meta: true): const ExtendSelectionToLineBreakIntent(forward: false, collapseSelection: false, expand: true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable, but I would slightly prefer having a different intent since collapseSelection and expand can't both be true and currently it relies on a run time assert.
d10f76e to
fa01357
Compare
Command + shift + left/right arrow should expand to the beginning/end of the line, not extend or pivot like other platforms.
Mac single line
Other platforms single line
Mac multi line
Mac single line
Other platforms multi line
Fixes #93883 (comment)