Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache max details height of SelectBox #171779

Merged
merged 1 commit into from Jan 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/vs/base/browser/ui/selectBox/selectBoxCustom.ts
Expand Up @@ -100,6 +100,7 @@ export class SelectBoxList extends Disposable implements ISelectBoxDelegate, ILi
private _hasDetails: boolean = false;
private selectionDetailsPane!: HTMLElement;
private _skipLayout: boolean = false;
private _cachedMaxDetailsHeight?: number;

private _sticky: boolean = false; // for dev purposes only

Expand Down Expand Up @@ -269,6 +270,7 @@ export class SelectBoxList extends Disposable implements ISelectBoxDelegate, ILi
this.options = options;
this.selectElement.options.length = 0;
this._hasDetails = false;
this._cachedMaxDetailsHeight = undefined;

this.options.forEach((option, index) => {
this.selectElement.add(this.createOption(option.text, index, option.isDisabled));
Expand Down Expand Up @@ -561,7 +563,10 @@ export class SelectBoxList extends Disposable implements ISelectBoxDelegate, ILi
this.selectList.layout();
let listHeight = this.selectList.contentHeight;

const maxDetailsPaneHeight = this._hasDetails ? this.measureMaxDetailsHeight() : 0;
if (this._hasDetails && this._cachedMaxDetailsHeight === undefined) {
this._cachedMaxDetailsHeight = this.measureMaxDetailsHeight();
}
const maxDetailsPaneHeight = this._hasDetails ? this._cachedMaxDetailsHeight! : 0;

const minRequiredDropDownHeight = listHeight + verticalPadding + maxDetailsPaneHeight;
const maxVisibleOptionsBelow = ((Math.floor((maxSelectDropDownHeightBelow - verticalPadding - maxDetailsPaneHeight) / this.getHeight())));
Expand Down