Notebooks: Add Command + Keyboard Shortcut to Clear Outputs of Active Cell (#6169)

* Add command to clear cell output with test

* Fix typo

* PR Comments
This commit is contained in:
Chris LaFreniere
2019-06-26 15:19:12 -07:00
committed by GitHub
parent caba5c9d26
commit 77fb060fde
10 changed files with 110 additions and 3 deletions

View File

@@ -42,6 +42,9 @@ export async function activate(extensionContext: vscode.ExtensionContext): Promi
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.runallcells', () => {
runAllCells();
}));
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.clearactivecellresult', () => {
clearActiveCellOutput();
}));
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.addcell', async () => {
let cellType: CellType;
try {
@@ -152,6 +155,19 @@ async function runActiveCell(): Promise<void> {
}
}
async function clearActiveCellOutput(): Promise<void> {
try {
let notebook = azdata.nb.activeNotebookEditor;
if (notebook) {
await notebook.clearOutput();
} else {
throw new Error(noNotebookVisible);
}
} catch (err) {
vscode.window.showErrorMessage(getErrorMessage(err));
}
}
async function runAllCells(): Promise<void> {
try {
let notebook = azdata.nb.activeNotebookEditor;