Skip to content

Commit

Permalink
Clear output area when empty (jupyterlab#16208)
Browse files Browse the repository at this point in the history
* Clear output area when empty

* Save last cell output height

* Moving some variables for clearing cell output

* Check if height is defined/not defined before changing it

---------

Co-authored-by: krassowski <5832902+krassowski@users.noreply.github.com>
  • Loading branch information
2 people authored and JasonWeill committed Apr 22, 2024
1 parent adb667f commit aa15ad2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/cells/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,15 @@ export class CodeCell extends Cell<ICodeCellModel> {
}
// This is to hide/show icon on single line output.
this.updatePromptOverlayIcon();

// Clear output area when empty
const height = this.outputArea.node.style.height;
if (this.model.outputs.length === 0 && height !== '') {
this._lastOutputHeight = height;
this.outputArea.node.style.height = '';
} else if (this.model.outputs.length > 0 && height === '') {
this.outputArea.node.style.height = this._lastOutputHeight;
}
}

/**
Expand Down Expand Up @@ -1656,6 +1665,7 @@ export class CodeCell extends Cell<ICodeCellModel> {
private _syncScrolled = false;
private _lastOnCaretMovedHandler: () => void;
private _lastTarget: HTMLElement | null = null;
private _lastOutputHeight = '';
}

/**
Expand Down

0 comments on commit aa15ad2

Please sign in to comment.