Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 1x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x | import * as vscode from 'vscode';
export const executeNotebookCell = {
id: 'mentor.command.executeNotebookCell',
handler: async (notebookUri: string, cellIndex: number): Promise<void> => {
try {
const uri = vscode.Uri.parse(notebookUri);
const document = await vscode.workspace.openNotebookDocument(uri);
const editor = await vscode.window.showNotebookDocument(document);
if (cellIndex < document.cellCount) {
const cell = document.cellAt(cellIndex);
const range = new vscode.NotebookRange(cellIndex, cellIndex + 1);
editor.selection = range;
await vscode.commands.executeCommand('notebook.cell.execute', {
uri: cell.notebook.uri,
cellIndex: cell.index
});
} else {
vscode.window.showErrorMessage(`Cell index ${cellIndex} is out of range`);
}
} catch (error: any) {
vscode.window.showErrorMessage(`Failed to execute notebook cell: ${error.message}`);
}
}
}; |