Skip to content

Commit

Permalink
fix bug that causes error output when execution an empty cell
Browse files Browse the repository at this point in the history
  • Loading branch information
allen-li1231 committed Jan 25, 2024
1 parent f5081ea commit 8ad8d3b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/common/dataStructure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export interface ParagraphSetting {

export interface ParagraphResult {
code: string;
msg: ParagraphResultMsg[]
msg?: ParagraphResultMsg[]
}

export interface ParagraphResultMsg {
Expand Down
6 changes: 3 additions & 3 deletions src/common/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ export function parseParagraphResultToCellOutput(
let encoder = new TextEncoder();
let textOutput = '', htmlOutput = '', errorOutput = '';
let imageOutputs: Uint8Array[] = [];
for (let msg of results['msg']) {
if (msg['type'] === 'HTML') {
for (let msg of results.msg ?? []) {
if (msg.type === 'HTML') {
htmlOutput += msg.data;
}
else if (msg['type'] === 'IMG') {
else if (msg.type === 'IMG') {
let data = Uint8Array.from(atob(msg.data), c => c.charCodeAt(0));
imageOutputs.push(data);
}
Expand Down
10 changes: 7 additions & 3 deletions src/extension/notebookKernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,11 @@ export class ZeppelinKernel {
cell.notebook.metadata.id, cell.metadata.id, sync
);
if (!sync) {
return res?.data;
return res?.data ?? [];
}

if (!res?.data.body) {
return [];
}

let paragraphResult = <ParagraphResult> res?.data.body;
Expand Down Expand Up @@ -768,9 +772,9 @@ export class ZeppelinKernel {
try {
await this.instantUpdatePollingParagraphs();

let cellOutput = await this._runParagraph(cell, true);
execution.start(Date.now());
if (cellOutput.length > 0) {
let cellOutput = await this._runParagraph(cell, true);
if (cellOutput && cellOutput.length > 0) {
execution.replaceOutput(new vscode.NotebookCellOutput(cellOutput));
}
else {
Expand Down

0 comments on commit 8ad8d3b

Please sign in to comment.