Notebooks: Fix Grids Not Rendering when Unsaved Notebook Reloaded (#12483)

* Clear Output and fix output change

* Fix tests after forced clear + append output
This commit is contained in:
Chris LaFreniere
2020-09-18 18:40:21 -07:00
committed by GitHub
parent 63adfd4d38
commit 117ecfebd1
3 changed files with 25 additions and 21 deletions

View File

@@ -129,9 +129,11 @@ export class NotebookTextFileModel {
}
public transformAndApplyEditForOutputUpdate(contentChange: NotebookContentChange, textEditorModel: ITextEditorModel): boolean {
this.transformAndApplyEditForClearOutput(contentChange, textEditorModel);
if (Array.isArray(contentChange.cells[0].outputs) && contentChange.cells[0].outputs.length > 0) {
let newOutput = JSON.stringify(contentChange.cells[0].outputs[contentChange.cells[0].outputs.length - 1], undefined, ' ');
if (contentChange.cells[0].outputs.length > 1) {
for (let i = 0; i < contentChange.cells[0].outputs.length; i++) {
let newOutput = JSON.stringify(contentChange.cells[0].outputs[i], undefined, ' ');
if (i > 0) {
newOutput = ', '.concat(newOutput);
} else {
newOutput = '\n'.concat(newOutput).concat('\n');
@@ -149,9 +151,10 @@ export class NotebookTextFileModel {
range: new Range(endOutputsRange.startLineNumber, endOutputsRange.startColumn, endOutputsRange.startLineNumber, endOutputsRange.startColumn),
text: newOutput
}]);
return true;
}
}
return true;
}
return false;
}

View File

@@ -392,6 +392,7 @@ export class DataResourceDataProvider implements IGridDataProvider {
let rows = await this._queryRunner.getQueryRows(i, numRows, this._batchId, this._id);
this.convertData(rows);
}
this.cellModel.sendChangeToNotebook(NotebookChangeType.CellOutputUpdated);
}
private convertData(rows: ResultSetSubset): void {