-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Support cell-level custom context from extensions #146686
Comments
We could do a low-impact thing like extending the setContext command to allow setting a value within a certain cell sub-context. commands.executeCommand('setContext', 'jupyter.runByLineInProgress', true, { cellUri: cell.uri }); Or real API on NotebookCell export interface NotebookCell {
setContext(key: string, value: any): void;
} |
It was pointed out that we can pretty much do this without new API, maybe using an array context key and the "in" operator: https://code.visualstudio.com/api/references/when-clause-contexts#in-conditional-operator We have a set of 'resource' context keys which are bound to the editor resource URI, but not the cell URI. Cell URIs are the document URI plus some fragment. I could bind those keys to the cell URI, or add a new set (like Also, the fragment is not exposed. The So to give an example, one scenario is
|
@roblourens Do you want this to be something per notebook document or per notebook editor? |
Per document. So the same cell in split editors gets the same menu items. |
I think I would actually add a new context key, |
Verification: use "inspect context keys" to check that there is a cellResource key on the cell, and is a toString'd cell URI with fragment |
Verified there was a variable |
Notebook extensions often need to set a cell-level context for actions that are different per-cell. Currently there is no way to do that, except for workarounds like changing the global context based on the currently selected cell.
Examples: Run by line, #146353
Currently extensions can use the
setContext
command to set global context values. Custom trees allow setting a single context value on individual items with thecontextValue
property. I think that only the tree provider can set this. In notebooks we would ideally allow different extensions to set different context key/values on a cell.The text was updated successfully, but these errors were encountered: