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 notebookKernel contextkey #143163

Merged
merged 1 commit into from
Feb 16, 2022

Conversation

gjsjohnmurray
Copy link
Contributor

This PR allows microsoft/vscode-jupyter#9037 to be fixed.

It adds a notebookKernel contextkey (string type) which will contain the id of the selected kernel.

Kernel id syntax is publisher.name/notebookControllerId

notebookControllerId is the identifier string passed in the first parameter of the vscode.notebooks.createNotebookController method.

The new contextkey can then be used in the when clause of an extension's contribution to the interactive/toolbar menu (for example) to prevent an extension's commands from displaying when the interactive window is using a kernel contributed by a different extension.

For example, extension ms-toolsai.jupyter would add:

  "when": "notebookKernel =~ /^ms-toolsai.jupyter\//"

to its contributions to the interactive/toolbar menu.

pinging @rchiodo

@gjsjohnmurray
Copy link
Contributor Author

pinging @rebornix

@rebornix
Copy link
Member

This is a good approach for limiting actions to notebook using kernels a specific extension contributes. @gjsjohnmurray thanks for your contribution, it looks great!

@rebornix rebornix merged commit 7bd78a9 into microsoft:main Feb 16, 2022
@rebornix
Copy link
Member

rebornix commented Feb 16, 2022

We might want to change the context keys to notebookController* later, currently we call them all notebookKernel*. cc @roblourens

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.

2 participants