Skip to content

Allow keybindings to override chord keys when there is a when condition #12187

Closed

Description

@Tyriar
  • VSCode Version: Code - Insiders 1.6.0-insider (0619ede, 2016-09-16T08:03:24.238Z)
  • OS Version: Linux x64 4.4.0-31-generic, Ubuntu 16.04

Based on my testing at least on Linux, I cannot bind ctrl+k as a keybinding due to the chord keybindings. This blocks #6603 in allowing a ⌘K keybinding to clear the terminal ("when": "terminalFocus"). I think it's reasonable to allow overriding of the chords at the very least when there is a "when" condition.

Steps to Reproduce:

  1. Define a keybinding as ctrl/cmd+k with a "when" condition
  2. Try using it

Activity

  1. added
    feature-request
    on Sep 17, 2016
  2. Tyriar commented on Sep 17, 2016

    @Tyriar
    ContributorAuthor

    alexandrudima I can implement this if you find the proposal reasonable. KeybindingResolver.resolve looks like the place to do it.

  3. added
    keybindings
    on Sep 19, 2016
  4. alexdima commented on Sep 20, 2016

    @alexdima
    Member

    I think it is doable, all the relevant logic is in KeybindingResolver. There are two maps involved, _map and _chords. When registering a chord ctrl+k ctrl+d, the _map gets an entry for ctrl+k that lets the logic know that it is a chord, plus _chords[ctrl+k] gets an entry for ctrl+d.

    So far, the code assumes that if a keybinding is the beginning of a chord it cannot be a "direct" keybinding. I have found this consistent with Visual Studio, for example.

    PR + tests welcome.

  5. Novack commented on Oct 21, 2016

    @Novack

    Following!

  6. Tyriar commented on Nov 23, 2016

    @Tyriar
    ContributorAuthor

    We're not actually going forward with this, instead we're making the cmd+k keybinding for the terminal weight more as doing it the way proposed in the issue would be a pretty radical change in how it works.

  7. Novack commented on Nov 23, 2016

    @Novack

    For context, I use CTRL+K for toggle comment line, and I had to manually search and remove ALL chord keybindings which start with CTRL+K, in order to be able to use CTRL+K in editor, for my desired purpose.

  8. Tyriar commented on Nov 23, 2016

    @Tyriar
    ContributorAuthor

    @Novack- after discussing with alexandrudima, you should not need to remove the chord keybindings as your custom keybindings should "weight more".

  9. Novack commented on Nov 23, 2016

    @Novack

    Woot! I just tried and it works, thank you Daniel Imms (@Tyriar)!

    Is this a recent change? With Code 1.6, CTRL+K keybinding did not worked until I added new rules removing the default chords which start with CTRL+K. I can remove a lot of rules from there now :)

  10. Tyriar commented on Nov 26, 2016

    @Tyriar
    ContributorAuthor

    I think it's always worked like this

  11. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestkeybindings

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions