Skip to content

Commit

Permalink
fix: Executing several cells
Browse files Browse the repository at this point in the history
Fixes #315

Signed-off-by: Gordon Smith <GordonJSmith@gmail.com>
  • Loading branch information
GordonSmith committed Aug 18, 2022
1 parent dca5087 commit 54b9788
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ecl-sample/notebooks/wuResult.eclnb

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions src/notebook/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,17 @@ export class Controller {
}
}

private async executeOJS(cell: vscode.NotebookCell, cells: vscode.NotebookCell[]): Promise<vscode.NotebookCellOutputItem> {
private async executeOJS(cell: vscode.NotebookCell): Promise<vscode.NotebookCellOutputItem> {
const items = [];
cell.notebook.getCells().filter(c => c !== cell).forEach(otherCell => {

const cells = cell.notebook.getCells(new vscode.NotebookRange(0, cell.index));
for (const otherCell of cells) {
otherCell.outputs.forEach(op => {
op.items.filter(item => item.mime === "application/hpcc.wu+json").forEach(item => {
items.push(item);
});
});
});
}

const eclResults: WUOutput[] = [];
for (const item of items) {
Expand Down Expand Up @@ -186,16 +188,16 @@ export class Controller {
execution.executionOrder = ++this._executionOrder;
execution.start(Date.now());
const cellOutput = new vscode.NotebookCellOutput([], {});
execution.replaceOutput(cellOutput);
await execution.replaceOutput(cellOutput);
switch (cell.document.languageId) {
case "ecl":
cellOutput.items.push(await this.executeECL(cell));
break;
case "ojs":
cellOutput.items.push(await this.executeOJS(cell, cells));
cellOutput.items.push(await this.executeOJS(cell));
break;
}
execution.replaceOutput(cellOutput);
await execution.replaceOutput(cellOutput);
execution.end(true, Date.now());
}

Expand Down

0 comments on commit 54b9788

Please sign in to comment.