Skip to content

Commit 566d42f

Browse files
committed
Update eval
1 parent b556b84 commit 566d42f

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

src/notebook.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ export class RNotebookProvider implements vscode.NotebookContentProvider, vscode
117117
private disposables: vscode.Disposable[] = [];
118118
private readonly notebooks = new Map<string, RNotebook>();
119119

120+
private runIndex: number = 0;
121+
120122
constructor(kernelScript: string) {
121123
this.kernelScript = kernelScript;
122124
this.disposables.push(
@@ -276,30 +278,28 @@ export class RNotebookProvider implements vscode.NotebookContentProvider, vscode
276278
return;
277279
}
278280

279-
let output = '';
280-
let error: Error;
281-
282281
if (notebook) {
283282
try {
284-
output = await notebook.eval(cell);
283+
cell.metadata.runState = vscode.NotebookCellRunState.Running;
284+
const start = +new Date();
285+
cell.metadata.runStartTime = start;
286+
cell.metadata.executionOrder = ++this.runIndex;
287+
const output = await notebook.eval(cell);
288+
cell.outputs = [{
289+
outputKind: vscode.CellOutputKind.Text,
290+
text: output,
291+
}];
292+
cell.metadata.runState = vscode.NotebookCellRunState.Success;
293+
cell.metadata.lastRunDuration = +new Date() - start;
285294
} catch (e) {
286-
error = e;
295+
cell.outputs = [{
296+
outputKind: vscode.CellOutputKind.Error,
297+
evalue: e.toString(),
298+
ename: '',
299+
traceback: [],
300+
}];
287301
}
288302
}
289-
290-
if (error) {
291-
cell.outputs = [{
292-
outputKind: vscode.CellOutputKind.Error,
293-
evalue: error.toString(),
294-
ename: '',
295-
traceback: [],
296-
}];
297-
} else {
298-
cell.outputs = [{
299-
outputKind: vscode.CellOutputKind.Text,
300-
text: output,
301-
}];
302-
}
303303
}
304304

305305
async executeAllCells(document: vscode.NotebookDocument): Promise<void> {

0 commit comments

Comments
 (0)