Allow extensions to contribute a default when clause to be used when a user add a key binding for the command
See original GitHub issueRelated: https://github.com/microsoft/vscode/issues/40389#issuecomment-738419359
Commands today can often have complex when clauses for the conditional for when they should apply, but these conditions aren’t able to be expressed to the user when they add a key binding. Maybe we could add a defaultWhen or keybindingWhen (or something like that) property to commands in the package.json, so that when a user add a key binding for that command, the when clause would be populated with that value.
Alternatively, I was thinking that we could re-use the when clause of the command’s commandPalette contribution to get at a reasonable default, but it might be tricky and we’d need to discount any false clauses.
Another option (though larger in scope of what I am proposing/wanting here) would be to allow having an entry in the keybindings contribution point without the actual key, so that it would be used as the “template” for when a user adds a binding. This could also double as a way for extensions to opt-out commands from key bindings altogether, by setting "when": false like the commandPalette contribution point. As there are plenty of commands that an extension can have that they can’t really support a user adding a keybinding for. But that 2nd point, is I think out of scope of this issue.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:5 (3 by maintainers)

 Top Related Medium Post
Top Related Medium Post Top Related StackOverflow Question
Top Related StackOverflow Question
@alexdima I felt the feature is asking for more like
defaultWhenorkeybindingWhen(or something like that) property to commands in the package.json,whenclause of the command’s commandPalette contribution to get at a reasonable default, but it might be tricky and we’d need to discount any false clauses.Since Keybindings editor is just one kind of UI to add keybinding and users can also add keybindings directly from json file, I thought it shall be something that has to be supported by core keybindings.
This feature request has not yet received the 20 community upvotes it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our documentation.
Happy Coding!