This commit is contained in:
rebornix 2021-03-31 11:25:00 -07:00
parent ca980ecfac
commit f1c4a8676e
No known key found for this signature in database
GPG key ID: 181FC90D15393C20
4 changed files with 15 additions and 2 deletions

View file

@ -362,6 +362,7 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
updateOptions(options: IListViewOptionsUpdate) {
if (options.additionalScrollHeight !== undefined) {
this.additionalScrollHeight = options.additionalScrollHeight;
this.scrollableElement.setScrollDimensions({ scrollHeight: this.scrollHeight });
}
if (options.smoothScrolling !== undefined) {

View file

@ -694,6 +694,7 @@ export interface INotebookCellList {
domFocus(): void;
setCellSelection(element: ICellViewModel, range: Range): void;
style(styles: IListStyles): void;
getRenderHeight(): number;
updateOptions(options: IListOptions<ICellViewModel>): void;
layout(height?: number, width?: number): void;
dispose(): void;

View file

@ -1428,8 +1428,15 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
this._dimension = new DOM.Dimension(dimension.width, dimension.height);
DOM.size(this._body, dimension.width, dimension.height - (this._useGlobalToolbar ? /** Toolbar height */ 26 : 0));
this._list.updateOptions({ additionalScrollHeight: this._scrollBeyondLastLine ? dimension.height - SCROLLABLE_ELEMENT_PADDING_TOP : SCROLLABLE_ELEMENT_PADDING_TOP });
this._list.layout(dimension.height - SCROLLABLE_ELEMENT_PADDING_TOP, dimension.width);
if (this._list.getRenderHeight() < dimension.height - SCROLLABLE_ELEMENT_PADDING_TOP) {
// the new dimension is larger than the list viewport, update its additional height first, otherwise the list view will move down a bit (as the `scrollBottom` will move down)
this._list.updateOptions({ additionalScrollHeight: this._scrollBeyondLastLine ? Math.max(0, (dimension.height - SCROLLABLE_ELEMENT_PADDING_TOP - 50)) : SCROLLABLE_ELEMENT_PADDING_TOP });
this._list.layout(dimension.height - SCROLLABLE_ELEMENT_PADDING_TOP, dimension.width);
} else {
// the new dimension is smaller than the list viewport, if we update the additional height, the `scrollBottom` will move up, which moves the whole list view upwards a bit. So we run a layout first.
this._list.layout(dimension.height - SCROLLABLE_ELEMENT_PADDING_TOP, dimension.width);
this._list.updateOptions({ additionalScrollHeight: this._scrollBeyondLastLine ? Math.max(0, (dimension.height - SCROLLABLE_ELEMENT_PADDING_TOP - 50)) : SCROLLABLE_ELEMENT_PADDING_TOP });
}
this._overlayContainer.style.visibility = 'visible';
this._overlayContainer.style.display = 'block';

View file

@ -1246,6 +1246,10 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
}
}
getRenderHeight() {
return this.view.renderHeight;
}
layout(height?: number, width?: number): void {
this._isInLayout = true;
super.layout(height, width);