Skip to content

Commit

Permalink
fix cell height when updating output (#14621)
Browse files Browse the repository at this point in the history
Signed-off-by: Jonah Iden <[email protected]>
  • Loading branch information
jonah-iden authored Dec 13, 2024
1 parent 5c7ffaa commit 35d458a
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ export async function outputWebviewPreload(ctx: PreloadContext): Promise<void> {
readonly element: HTMLElement;
readonly outputElements: OutputContainer[] = [];

private cellHeight: number = 0;

constructor(public cellHandle: number, cellIndex?: number) {
this.element = document.createElement('div');
this.element.style.outline = '0';
Expand Down Expand Up @@ -183,6 +185,7 @@ export async function outputWebviewPreload(ctx: PreloadContext): Promise<void> {
outputContainer = new OutputContainer(output, items, this);
this.element.appendChild(outputContainer.containerElement);
this.outputElements.splice(index, 0, outputContainer);
this.updateCellHeight(this.cellHeight);
}

return outputContainer;
Expand All @@ -206,7 +209,8 @@ export async function outputWebviewPreload(ctx: PreloadContext): Promise<void> {
this.element.style.visibility = 'hidden';
}

public updateCellHeight(cellKind: number, height: number): void {
public updateCellHeight(height: number): void {
this.cellHeight = height;
let additionalHeight = 54.5;
additionalHeight -= cells[0] === this ? 2.5 : 0; // first cell
additionalHeight -= this.outputElements.length ? 0 : 5.5; // no outputs
Expand Down Expand Up @@ -763,7 +767,7 @@ export async function outputWebviewPreload(ctx: PreloadContext): Promise<void> {
cellHandle = event.data.cellHandle;
const cell = cells.find(c => c.cellHandle === cellHandle);
if (cell) {
cell.updateCellHeight(event.data.cellKind, event.data.height);
cell.updateCellHeight(event.data.height);
}
break;
case 'outputVisibilityChanged':
Expand Down

0 comments on commit 35d458a

Please sign in to comment.