Repository navigation
Windows home/end shortcuts - #90840
Conversation
|
@LongCatIsLooong FYI this is going to conflict with your refactor #90684. I'm still working on this a bit so maybe I should just wait until your PR is merged and then make these changes in the new pattern. |
|
From triage: Looks like #90684 is submitted now 🥳 |
|
Will update this, thanks! |
cda763a to
1b53858
Compare
| ? TextSelection.fromPosition(newExtent) | ||
| : textBoundarySelection.extendTo(newExtent); | ||
|
|
||
| // If collapseAtReversal is true and would have an effect, collapse it. |
There was a problem hiding this comment.
@LongCatIsLooong How would you prefer that we implement this "collapseAtReversal" feature within your new Actions setup? Feel free to butcher this if it's totally off, I'm still getting the hang of your new refactor so I've just put down a quick attempt.
There was a problem hiding this comment.
Yeah this makes sense to me!
| SingleActivator(LogicalKeyboardKey.end): ExtendSelectionToLineBreakIntent(forward: true, collapseSelection: true), | ||
| SingleActivator(LogicalKeyboardKey.home, shift: true): ExtendSelectionToLineBreakIntent(forward: false, collapseSelection: false), | ||
| SingleActivator(LogicalKeyboardKey.end, shift: true): ExtendSelectionToLineBreakIntent(forward: true, collapseSelection: false), | ||
| SingleActivator(LogicalKeyboardKey.home, shift: true): ExtendSelectionToLineBreakIntent(forward: false, collapseSelection: false, collapseAtReversal: true), |
There was a problem hiding this comment.
I tried on windows 10, it doesn't seem to collapse at reversal? E.g., the initial selection is aaaaaa|bbbbb, I pressed shift-End it became aaaaaa<bbbbb> and then I pressed shift-Home it became <aaaaaa>bbbbb. This was tested in the explorer's address bar.
There was a problem hiding this comment.
Thanks good catch. My table in the description of this PR is correct, but I got this code backwards when I ported it. I've fixed it.
I also double checked Linux (gedit). It has the same behavior as Windows.
|
@LongCatIsLooong In need of a re-review when you have a chance. |
| // * Meta + backspace | ||
| static const Map<ShortcutActivator, Intent> _windowsShortcuts = _linuxShortcuts; | ||
| static const Map<ShortcutActivator, Intent> _windowsShortcuts = <ShortcutActivator, Intent>{ | ||
| ..._linuxShortcuts, |
There was a problem hiding this comment.
nit: _commonShortcuts is the same as _linuxShortcuts iirc? I probably should have referenced _commonShortcuts here it's a bit confusing why we are including _linuxShortcuts for windows.
There was a problem hiding this comment.
I've reworked this to just use ..._commonShortcuts here. I had to duplicate 4 entries but I think that's fine.
| SingleActivator(LogicalKeyboardKey.arrowUp, shift: true): DoNothingAndStopPropagationTextIntent(), | ||
| SingleActivator(LogicalKeyboardKey.end, shift: true): DoNothingAndStopPropagationTextIntent(), | ||
| SingleActivator(LogicalKeyboardKey.home, shift: true): DoNothingAndStopPropagationTextIntent(), | ||
| SingleActivator(LogicalKeyboardKey.end, control: true): DoNothingAndStopPropagationTextIntent(), |
There was a problem hiding this comment.
Something related but doesn't have to be addressed in the pull request: would it be possible if we create a Map subclass that always returns DoNothingAndStopPropagationTextIntent? Or is it possible we relax what the Shortcuts widget use for Intent lookup, so it takes a function of type ShortcutActivator => Intent (instead of a Map)?
There was a problem hiding this comment.
Yeah that might help us avoid a lot of this code. @gspencergoog Do you have any opinion?
There was a problem hiding this comment.
We could make a different constructor for Shortcuts that takes a function instead of a Map. I'd want to keep the one that takes a Map, though. One additional benefit of the function over the map would be that it might be faster to construct: long maps can get slow to construct on each build.
There was a problem hiding this comment.
That would work, so all of this _webShortcuts map would just be a check for kIsWeb and if so return DoNothingAndStopPropagationTextIntent. I'll keep this in mind next time I'm working on this code.
| ? TextSelection.fromPosition(newExtent) | ||
| : textBoundarySelection.extendTo(newExtent); | ||
|
|
||
| // If collapseAtReversal is true and would have an effect, collapse it. |
There was a problem hiding this comment.
Yeah this makes sense to me!
| ), | ||
| )); | ||
|
|
||
| // Focus on the EditableText, which is a TextEditingActionTarget. |
There was a problem hiding this comment.
I thought I removed this file, since TextEditingActionTarget is gone?
There was a problem hiding this comment.
So did I but I also noticed that text_editing_action_target.dart was still in the repo unused! I removed it in this PR. Maybe it accidentally came back in a merge or something and we missed it?
I went ahead and deleted this test file too now.
This PR fixes some keyboard shortcuts on Windows that were missing/incorrect. From the issue, these were my observations before starting this PR:
Fixes #77020
I've opened a separate issue for the incorrect movement between lines: #90993