-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
Add support for three or more chord keyboard shortcuts #175253
Add support for three or more chord keyboard shortcuts #175253
Conversation
@dyedgreen Thank you for your PR. In order for me to be able to review it, please accept the Contributor License Agreement (see above comment) |
Thanks for getting back to me so quickly @alexdima! I’m checking with my employer to see if I need to include them here / should accept purely myself and will accept the CLA here as soon as they get back to me 😅 |
@microsoft-github-policy-service agree company="Jane Street" |
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.
Thanks for the PR @dyedgreen (a fellow OCaml'er, I guess? 🐫)
The PR looks good, a couple of inline comments.
Thanks for the review @ulugbekna! I've made a few minor tweaks based on your comments, let me know if they make sense. And yes, we famously write even our hardware in OCaml 😄 |
Just to check, is there anything else required from my side for this to be merged? |
This is awaiting @alexdima 's review. He's very occupied right now, but we haven't forgotten about the PR. Thanks for patience with this |
@dyedgreen btw, would you be interested in implementing support for multi-chord keybindings in the keybindings editor? The feature would become complete and more likely to be shipped. |
I can take a look at how hard that would be 👍 |
@ulugbekna I've updated the PR to also allow unlimited chords in the keybinding recording widgets. This means if you miss-click while recording, you have to abort (escape) and retry; previously it would let you cycle and try again although I personally found that confusing. |
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.
First, big thanks for being active with the PR and great work. The changes look good. I see two issues:
- Search by keybinding prefix works only for 2 chords, ie:
cmd+k
finds keybindings that have their first chordcmd+k
cmd+k cmd+k
finds keybindings that have their 1st and 2nd chordcmd+k cmd+k
- but
cmd+k cmd+k cmd+k
doesn’t find the keybindingcmd+k cmd+k cmd+k cmd+i
- user has to insert the exact keybinding to find itI think it would be great to fix before merging.
I think this needs to be fixed before merging.
- In the define keybinding widget, we don't resize on overflow. I don't think people would be defining KBs with > 5 chords, but this remains an issue.
@sandy081 it would be great to have a review from you for the keybinding widget changes |
Upd: I'll make a commit to this PR that restricts the UI to 2 chords, so that we don't burden you with more work and merge the PR sooner. We'll address the UI changes in another PR. |
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 looks great! I've pushed a change to limit the chord count to 2 in the widget for now. We should improve this in the widget itself via separate PRs. However, there is one problem where modifier only keybindings no longer work e.g.:
{
"key": "shift shift",
"command": "actions.find"
}
|
||
if (isSingleModiferChord) { | ||
const [dispatchKeyname,] = keybinding.getSingleModifierDispatchChords(); | ||
firstChord = dispatchKeyname; | ||
currentChord = dispatchKeyname; | ||
currentChord = null; |
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.
Does a keybinding like shift shift
still work after this change?
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 it might not. I’ll take a look at how we can make this work again 👀
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 pushed some changes to restore the previous behavior. The way the single modifier chords are set-up, they can't be chorded to arbitrary length, but I feel like that's okay? (It fully restores the old behavior, while allowing arbitrary length chords for regular keys.)
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.
👍 Thank you!
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.
great work, thanks heaps! merging :-)
Thanks @dyedgreen and everybody involved for this. When can end users expect this commit to land in a stable MS release? |
Closes #6966.
Allow for three or more steps in keyboard shortcut cords.
This change only allows for such chords to be configured by the user in the key bindings JSON (by adding multiple steps with spaces; this was already parsed correctly, but the key binding machinery just ignored any keys past the first two).
The interactive keybinding recording widget is also updated to allow for unlimited length chord sequences.
Roughly, this is done by addressing the existing
TODO@chords
comments in the code.