You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow keybindings to override chord keys when there is a when condition #12187
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:
Define a keybinding as ctrl/cmd+k with a "when" condition
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.
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.
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.
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 :)
Activity
Tyriar commentedon Sep 17, 2016
alexandrudima I can implement this if you find the proposal reasonable.
KeybindingResolver.resolvelooks like the place to do it.alexdima commentedon Sep 20, 2016
I think it is doable, all the relevant logic is in
KeybindingResolver. There are two maps involved,_mapand_chords. When registering a chordctrl+k ctrl+d, the_mapgets an entry forctrl+kthat lets the logic know that it is a chord, plus_chords[ctrl+k]gets an entry forctrl+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.
Novack commentedon Oct 21, 2016
Following!
Tyriar commentedon Nov 23, 2016
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.
Novack commentedon Nov 23, 2016
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.
Tyriar commentedon Nov 23, 2016
@Novack- after discussing with alexandrudima, you should not need to remove the chord keybindings as your custom keybindings should "weight more".
Novack commentedon Nov 23, 2016
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 :)
Tyriar commentedon Nov 26, 2016
I think it's always worked like this