Skip to content
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

Merged
merged 24 commits into from
Mar 20, 2023

Conversation

dyedgreen
Copy link
Contributor

@dyedgreen dyedgreen commented Feb 23, 2023

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.

@dyedgreen dyedgreen marked this pull request as ready for review February 24, 2023 00:11
@dyedgreen dyedgreen changed the title Add support for three or more chords in shortcuts Add support for three or more chord keyboard shortcuts Feb 24, 2023
@alexdima alexdima self-requested a review February 24, 2023 14:31
@alexdima
Copy link
Member

@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)

@dyedgreen
Copy link
Contributor Author

dyedgreen commented Feb 24, 2023

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 😅

@dyedgreen
Copy link
Contributor Author

@microsoft-github-policy-service agree company="Jane Street"

@alexdima alexdima requested a review from ulugbekna March 7, 2023 14:29
ulugbekna
ulugbekna previously approved these changes Mar 8, 2023
Copy link
Contributor

@ulugbekna ulugbekna left a 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.

@ulugbekna ulugbekna self-assigned this Mar 9, 2023
@dyedgreen
Copy link
Contributor Author

dyedgreen commented Mar 9, 2023

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 😄

ulugbekna
ulugbekna previously approved these changes Mar 9, 2023
@dyedgreen
Copy link
Contributor Author

Just to check, is there anything else required from my side for this to be merged?

@ulugbekna
Copy link
Contributor

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

@ulugbekna
Copy link
Contributor

ulugbekna commented Mar 15, 2023

@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.

@dyedgreen
Copy link
Contributor Author

I can take a look at how hard that would be 👍

@dyedgreen
Copy link
Contributor Author

@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.

@dyedgreen dyedgreen requested review from ulugbekna and removed request for alexdima March 16, 2023 06:52
Copy link
Contributor

@ulugbekna ulugbekna left a 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:

  1. Search by keybinding prefix works only for 2 chords, ie:
    • cmd+k finds keybindings that have their first chord cmd+k
    • cmd+k cmd+k finds keybindings that have their 1st and 2nd chord cmd+k cmd+k
    • but cmd+k cmd+k cmd+k doesn’t find the keybinding cmd+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.

  1. 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.

image

@ulugbekna
Copy link
Contributor

@sandy081 it would be great to have a review from you for the keybinding widget changes

@ulugbekna
Copy link
Contributor

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.

Copy link
Member

@alexdima alexdima left a 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;
Copy link
Member

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?

Copy link
Contributor Author

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 👀

Copy link
Contributor Author

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.)

@sandy081 sandy081 self-requested a review March 16, 2023 13:57
@dyedgreen dyedgreen requested review from alexdima and removed request for sandy081 March 19, 2023 15:56
Copy link
Member

@alexdima alexdima left a comment

Choose a reason for hiding this comment

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

👍 Thank you!

@alexdima alexdima requested a review from ulugbekna March 20, 2023 07:16
Copy link
Contributor

@ulugbekna ulugbekna left a 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 :-)

@ulugbekna ulugbekna merged commit a0a30a5 into microsoft:main Mar 20, 2023
@anddam
Copy link

anddam commented Mar 20, 2023

Thanks @dyedgreen and everybody involved for this.

When can end users expect this commit to land in a stable MS release?

@alexdima alexdima added this to the March 2023 milestone Mar 20, 2023
@github-actions github-actions bot locked and limited conversation to collaborators May 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

enable keychords of 3 or more steps
4 participants