mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
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:
@@ -65,6 +65,10 @@
|
||||
"title": "%notebook.command.runactivecell%",
|
||||
"icon": "resources/dark/touchbar_run_cell.png"
|
||||
},
|
||||
{
|
||||
"command": "notebook.command.clearactivecellresult",
|
||||
"title": "%notebook.command.clearactivecellresult%"
|
||||
},
|
||||
{
|
||||
"command": "notebook.command.runallcells",
|
||||
"title": "%notebook.command.runallcells%"
|
||||
@@ -155,6 +159,10 @@
|
||||
"command": "notebook.command.runactivecell",
|
||||
"when": "notebookEditorVisible"
|
||||
},
|
||||
{
|
||||
"command": "notebook.command.clearactivecellresult",
|
||||
"when": "notebookEditorVisible"
|
||||
},
|
||||
{
|
||||
"command": "notebook.command.runallcells",
|
||||
"when": "notebookEditorVisible"
|
||||
@@ -234,6 +242,11 @@
|
||||
"key": "F5",
|
||||
"when": "activeEditor == workbench.editor.notebookEditor"
|
||||
},
|
||||
{
|
||||
"command": "notebook.command.clearactivecellresult",
|
||||
"key": "Ctrl+Shift+R",
|
||||
"when": "activeEditor == workbench.editor.notebookEditor"
|
||||
},
|
||||
{
|
||||
"command": "notebook.command.runallcells",
|
||||
"key": "Ctrl+Shift+F5",
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"notebook.command.open": "Open Notebook",
|
||||
"notebook.analyzeJupyterNotebook": "Analyze in Notebook",
|
||||
"notebook.command.runactivecell": "Run Cell",
|
||||
"notebook.command.clearactivecellresult": "Clear Cell Result",
|
||||
"notebook.command.runallcells": "Run Cells",
|
||||
"notebook.command.addcode": "Add Code Cell",
|
||||
"notebook.command.addtext": "Add Text Cell",
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user