mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-28 17:23:19 -05:00
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:
@@ -129,28 +129,31 @@ 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) {
|
||||
newOutput = ', '.concat(newOutput);
|
||||
} else {
|
||||
newOutput = '\n'.concat(newOutput).concat('\n');
|
||||
}
|
||||
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');
|
||||
}
|
||||
|
||||
// Execution count will always be after the end of the outputs in JSON. This is a sanity mechanism.
|
||||
let executionCountMatch = this.getExecutionCountRange(textEditorModel, contentChange.cells[0].cellGuid);
|
||||
if (!executionCountMatch || !executionCountMatch.range) {
|
||||
return false;
|
||||
}
|
||||
// Execution count will always be after the end of the outputs in JSON. This is a sanity mechanism.
|
||||
let executionCountMatch = this.getExecutionCountRange(textEditorModel, contentChange.cells[0].cellGuid);
|
||||
if (!executionCountMatch || !executionCountMatch.range) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let endOutputsRange = this.getEndOfOutputs(textEditorModel, contentChange.cells[0].cellGuid);
|
||||
if (endOutputsRange && endOutputsRange.startLineNumber < executionCountMatch.range.startLineNumber) {
|
||||
textEditorModel.textEditorModel.applyEdits([{
|
||||
range: new Range(endOutputsRange.startLineNumber, endOutputsRange.startColumn, endOutputsRange.startLineNumber, endOutputsRange.startColumn),
|
||||
text: newOutput
|
||||
}]);
|
||||
return true;
|
||||
let endOutputsRange = this.getEndOfOutputs(textEditorModel, contentChange.cells[0].cellGuid);
|
||||
if (endOutputsRange && endOutputsRange.startLineNumber < executionCountMatch.range.startLineNumber) {
|
||||
textEditorModel.textEditorModel.applyEdits([{
|
||||
range: new Range(endOutputsRange.startLineNumber, endOutputsRange.startColumn, endOutputsRange.startLineNumber, endOutputsRange.startColumn),
|
||||
text: newOutput
|
||||
}]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user