mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
Add setKernelSpecAndLanguageInfo to ipynb ext
This commit is contained in:
@@ -41,6 +41,26 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
});
|
||||
return vscode.workspace.applyEdit(edit);
|
||||
},
|
||||
setKernelSpecAndLanguageInfo: async (resource: vscode.Uri, kernelspec: unknown, language_info: unknown): Promise<boolean> => {
|
||||
const document = vscode.workspace.notebookDocuments.find(doc => doc.uri.toString() === resource.toString());
|
||||
if (!document) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
edit.replaceNotebookMetadata(resource, {
|
||||
...document.metadata,
|
||||
custom: {
|
||||
...(document.metadata.custom ?? {}),
|
||||
metadata: {
|
||||
...(document.metadata.custom?.metadata ?? {}),
|
||||
kernelspec: kernelspec,
|
||||
language_info: language_info
|
||||
},
|
||||
}
|
||||
});
|
||||
return vscode.workspace.applyEdit(edit);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user