Skip to content

Commit e6fd2cf

Browse files
committed
move output height calculation internal
1 parent 9675f47 commit e6fd2cf

3 files changed

Lines changed: 15 additions & 21 deletions

File tree

src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,9 @@ export class BackLayerWebView extends Disposable {
266266
let outputHeight = height === 0 ? 0 : height + 16;
267267

268268
if (cell) {
269-
let editorHeight = cell.editorHeight;
270269
let outputIndex = cell.outputs.indexOf(output);
271270
cell.updateOutputHeight(outputIndex, outputHeight);
272-
let totalOutputHeight = cell.getOutputTotalHeight();
273-
this.notebookEditor.layoutNotebookCell(cell, editorHeight + 32 /* code cell padding */ + totalOutputHeight);
271+
this.notebookEditor.layoutNotebookCell(cell, cell.getCellTotalHeight());
274272
}
275273
} else if (data.type === 'scroll-ack') {
276274
// const date = new Date();

src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,7 @@ export class CodeCell extends Disposable {
125125

126126
this.viewCell.editorHeight = e.contentHeight;
127127

128-
if (this.viewCell.outputs.length) {
129-
let outputHeight = this.viewCell.getOutputTotalHeight();
130-
notebookEditor.layoutNotebookCell(this.viewCell, viewCell.editorHeight + EDITOR_TOP_PADDING + EDITOR_BOTTOM_PADDING + 16 /** padding between input and output */ + outputHeight);
131-
} else {
132-
notebookEditor.layoutNotebookCell(this.viewCell, viewCell.editorHeight + EDITOR_TOP_PADDING + EDITOR_BOTTOM_PADDING);
133-
}
134-
128+
notebookEditor.layoutNotebookCell(this.viewCell, viewCell.getCellTotalHeight());
135129
}
136130

137131
}
@@ -198,8 +192,7 @@ export class CodeCell extends Disposable {
198192

199193
let editorHeight = templateData.editor!.getContentHeight();
200194
viewCell.editorHeight = editorHeight;
201-
let totalOutputHeight = viewCell.getOutputTotalHeight();
202-
notebookEditor.layoutNotebookCell(viewCell, viewCell.editorHeight + 32 + totalOutputHeight);
195+
notebookEditor.layoutNotebookCell(viewCell, viewCell.getCellTotalHeight());
203196
}));
204197

205198
if (viewCell.outputs.length > 0) {
@@ -213,9 +206,8 @@ export class CodeCell extends Disposable {
213206
this.renderOutput(currOutput, index, undefined);
214207
}
215208

216-
let totalOutputHeight = viewCell.getOutputTotalHeight();
217209
viewCell.editorHeight = totalHeight;
218-
this.notebookEditor.layoutNotebookCell(viewCell, viewCell.editorHeight + 32 + totalOutputHeight);
210+
this.notebookEditor.layoutNotebookCell(viewCell, viewCell.getCellTotalHeight());
219211
} else {
220212
// noop
221213
this.templateData.outputContainer!.style.display = 'none';
@@ -302,9 +294,7 @@ export class CodeCell extends Disposable {
302294
}
303295

304296
this.viewCell.updateOutputHeight(currIndex, height);
305-
const editorHeight = this.viewCell.editorHeight;
306-
const totalOutputHeight = this.viewCell.getOutputTotalHeight();
307-
this.notebookEditor.layoutNotebookCell(this.viewCell, editorHeight + 32 + totalOutputHeight);
297+
this.notebookEditor.layoutNotebookCell(this.viewCell, this.viewCell.getCellTotalHeight());
308298
}
309299
});
310300
elementSizeObserver.startObserving();
@@ -382,9 +372,7 @@ export class CodeCell extends Disposable {
382372
output.pickedMimeTypeIndex = pick;
383373

384374
this.renderOutput(output, index, nextElement);
385-
386-
let totalOutputHeight = this.viewCell.getOutputTotalHeight();
387-
this.notebookEditor.layoutNotebookCell(this.viewCell, this.viewCell.editorHeight + 32 + totalOutputHeight);
375+
this.notebookEditor.layoutNotebookCell(this.viewCell, this.viewCell.getCellTotalHeight());
388376
}
389377
}
390378

src/vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ export class CellViewModel extends Disposable implements ICellViewModel {
459459
return undefined;
460460
}
461461

462-
getOutputTotalHeight(): number {
462+
private getOutputTotalHeight(): number {
463463
this._ensureOutputsTop();
464464

465465
return this._outputsTop!.getTotalValue();
@@ -479,6 +479,14 @@ export class CellViewModel extends Disposable implements ICellViewModel {
479479
}
480480
}
481481

482+
getCellTotalHeight(): number {
483+
if (this.outputs.length) {
484+
return this.editorHeight + EDITOR_TOP_PADDING + EDITOR_BOTTOM_PADDING + 16 + this.getOutputTotalHeight();
485+
} else {
486+
return this.editorHeight + EDITOR_TOP_PADDING + EDITOR_BOTTOM_PADDING + this.getOutputTotalHeight();
487+
}
488+
}
489+
482490
protected _ensureOutputsTop(): void {
483491
if (!this._outputsTop) {
484492
const values = new Uint32Array(this._outputCollection.length);

0 commit comments

Comments
 (0)