diff --git a/extensions/notebook/package.json b/extensions/notebook/package.json index 395d664ace..b0b46e1e33 100644 --- a/extensions/notebook/package.json +++ b/extensions/notebook/package.json @@ -60,6 +60,10 @@ "title": "%notebook.command.runactivecell%", "icon": "resources/dark/touchbar_run_cell.png" }, + { + "command": "notebook.command.runallcells", + "title": "%notebook.command.runallcells%" + }, { "command": "notebook.command.addcode", "title": "%notebook.command.addcode%" @@ -145,6 +149,10 @@ "command": "notebook.command.runactivecell", "when": "notebookEditorVisible" }, + { + "command": "notebook.command.runallcells", + "when": "notebookEditorVisible" + }, { "command": "notebook.command.addcode", "when": "notebookEditorVisible" @@ -229,6 +237,11 @@ "key": "F5", "when": "activeEditor == workbench.editor.notebookEditor" }, + { + "command": "notebook.command.runallcells", + "key": "Ctrl+Shift+F5", + "when": "activeEditor == workbench.editor.notebookEditor" + }, { "command": "notebook.command.addcode", "key": "Ctrl+Shift+C", diff --git a/extensions/notebook/package.nls.json b/extensions/notebook/package.nls.json index 9d5ce3827a..d6819f16d1 100644 --- a/extensions/notebook/package.nls.json +++ b/extensions/notebook/package.nls.json @@ -9,6 +9,7 @@ "notebook.command.open": "Open Notebook", "notebook.analyzeJupyterNotebook": "Analyze in Notebook", "notebook.command.runactivecell": "Run Cell", + "notebook.command.runallcells": "Run Cells", "notebook.command.addcode": "Add Code Cell", "notebook.command.addtext": "Add Text Cell", "notebook.command.addcell": "Add Cell", diff --git a/extensions/notebook/src/extension.ts b/extensions/notebook/src/extension.ts index 1c925b59f5..4db3fab3ae 100644 --- a/extensions/notebook/src/extension.ts +++ b/extensions/notebook/src/extension.ts @@ -39,6 +39,9 @@ export async function activate(extensionContext: vscode.ExtensionContext): Promi extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.runactivecell', () => { runActiveCell(); })); + extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.runallcells', () => { + runAllCells(); + })); extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.addcell', async () => { let cellType: CellType; try { @@ -149,6 +152,19 @@ async function runActiveCell(): Promise { } } +async function runAllCells(): Promise { + try { + let notebook = azdata.nb.activeNotebookEditor; + if (notebook) { + await notebook.runAllCells(); + } else { + throw new Error(noNotebookVisible); + } + } catch (err) { + vscode.window.showErrorMessage(err); + } +} + async function addCell(cellType: azdata.nb.CellType): Promise { try { let notebook = azdata.nb.activeNotebookEditor;