-
Notifications
You must be signed in to change notification settings - Fork 2.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 schema for key binding file #10613
Conversation
532d3a3
to
68c7261
Compare
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.
@colin-grant-work I'm getting some odd behaviors, perhaps you can confirm:
- I sometimes get preferences when triggering (this happened for me initially, and later on as well when a proper schema was used):
keybindings-prefs.mp4
- The keybindings-widget does not seem to populate
key
which seems to be required by the schema (is it something we should update as part of the pr?):
This is not great, but not the fault of this code. Those suggestions are coming from the 'any string' suggestion machinery, and that appears to be very difficult to deactivate (happy for any suggestions!). @kenneth-marut-work has had the same difficulty in the breakpoint widget, and we haven't yet found a way to stop those string completions from coming through.
There seem to be a number of differences between our keybinding machinery and VSCode's. Their filename is |
I'm fine with the behavior we have for the moment, just wanted to point it out in case it was actually a bug with the pr, thank you for clarifying!
The filename difference is likely not so critical, the file is located in the user's home and we would not read
Sounds good to me! |
68c7261
to
fd40d94
Compare
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 can confirm that the recent changes work well 👍
I have a question, when we edit the keybinding for a command that has a context
(deprecated in favor of when
), we set context
correctly in the keymaps.json
. The issue is that hovering over context
does not yield any information:
For example:
[
{
"command": "workbench.action.debug.pause",
"keybinding": "ctrl+e",
"context": "inDebugMode"
},
{
"command": "-workbench.action.debug.pause",
"keybinding": "f6",
"context": "inDebugMode",
},
]
context.mp4
fd40d94
to
d9922a2
Compare
@vince-fugnitto, I've added the |
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.
The changes work well for me 👍
I confirmed that:
- the
keymaps.json
now has a schema - comments and trailing commas are permitted, and do not produce markers
- the schema has auto-completion, and intelligence (hovering) correctly
- the deprecated
context
is supported, and does not show up in the auto-completion
What it does
Fixes #5290 by adding a schema for keybindings that is updated whenever commands are registered or unregistered. It also adds an annotation to our various existing schemas (workspace files, tasks, debug, preferences) indicating that those files should be allowed to have trailing commas and comments, since they are parsed using the
JSONC
parser rather than standard JSON.How to test
keymaps.json
file either yourself or from the Keybindings Widget.ctrl + .
).command
args
), you should get a warning of some kind.Review checklist
Reminder for reviewers