mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 04:09:28 +00:00
Show codelens to ipynb json to open in notebook editor
This commit is contained in:
@@ -37,6 +37,16 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
}
|
||||
}));
|
||||
|
||||
vscode.languages.registerCodeLensProvider({ pattern: '**/*.ipynb' }, {
|
||||
provideCodeLenses: (document) => {
|
||||
if (document.uri.scheme === 'vscode-notebook-cell') {
|
||||
return [];
|
||||
}
|
||||
const codelens = new vscode.CodeLens(new vscode.Range(0, 0, 0, 0), { title: 'Open in Notebook Editor', command: 'ipynb.openIpynbInNotebookEditor', arguments: [document.uri] });
|
||||
return [codelens];
|
||||
}
|
||||
});
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('ipynb.newUntitledIpynb', async () => {
|
||||
const language = 'python';
|
||||
const cell = new vscode.NotebookCellData(vscode.NotebookCellKind.Code, '', language);
|
||||
@@ -55,6 +65,14 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
await vscode.window.showNotebookDocument(doc);
|
||||
}));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('ipynb.openIpynbInNotebookEditor', async (uri: vscode.Uri) => {
|
||||
if (vscode.window.activeTextEditor?.document.uri.toString() === uri.toString()) {
|
||||
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
|
||||
}
|
||||
const document = await vscode.workspace.openNotebookDocument(uri);
|
||||
await vscode.window.showNotebookDocument(document);
|
||||
}));
|
||||
|
||||
// Update new file contribution
|
||||
vscode.extensions.onDidChange(() => {
|
||||
vscode.commands.executeCommand('setContext', 'jupyterEnabled', vscode.extensions.getExtension('ms-toolsai.jupyter'));
|
||||
|
||||
Reference in New Issue
Block a user