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.
@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.
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.
I've created a new Intent as a subclass of DirectionalTextEditingIntent and I think it worked out cleaner 👍 .
| } | ||
|
|
||
| final TextPosition extent = textBoundarySelection.extent; | ||
| late final TextPosition position; |
There was a problem hiding this comment.
nit: is the late needed?
There was a problem hiding this comment.
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.
"whichever is closest to the target location" or something similar?
There was a problem hiding this comment.
Also maybe say this is typically only for macOS?
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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)