Skip to content

Commit

Permalink
Revert changes in listWidget and instead pass different arguments in …
Browse files Browse the repository at this point in the history
…quickInputList
  • Loading branch information
CrafterKolyan committed Feb 10, 2024
1 parent 8645f7b commit f7f0921
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
19 changes: 4 additions & 15 deletions src/vs/base/browser/ui/list/listWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ export class List<T> implements ISpliceable<T>, IDisposable {
return this.getFocus().map(i => this.view.element(i));
}

reveal(index: number, relativeTop?: number, paddingTop: number = 0, applyRelativeTopOnlyIfNotVisible: boolean = false): void {
reveal(index: number, relativeTop?: number, paddingTop: number = 0): void {
if (index < 0 || index >= this.length) {
throw new ListError(this.user, `Invalid index ${index}`);
}
Expand All @@ -1878,20 +1878,9 @@ export class List<T> implements ISpliceable<T>, IDisposable {
const elementHeight = this.view.elementHeight(index);

if (isNumber(relativeTop)) {
let applyRelativeTop: boolean;
if (applyRelativeTopOnlyIfNotVisible) {
const viewItemBottom = elementTop + elementHeight;
const scrollBottom = scrollTop + this.view.renderHeight;

applyRelativeTop = elementTop < scrollTop + paddingTop || viewItemBottom >= scrollBottom;
} else {
applyRelativeTop = true;
}
if (applyRelativeTop) {
// y = mx + b
const m = elementHeight - this.view.renderHeight + paddingTop;
this.view.setScrollTop(m * clamp(relativeTop, 0, 1) + elementTop - paddingTop);
}
// y = mx + b
const m = elementHeight - this.view.renderHeight + paddingTop;
this.view.setScrollTop(m * clamp(relativeTop, 0, 1) + elementTop - paddingTop);
} else {
const viewItemBottom = elementTop + elementHeight;
const scrollBottom = scrollTop + this.view.renderHeight;
Expand Down
6 changes: 5 additions & 1 deletion src/vs/platform/quickinput/browser/quickInputList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,11 @@ export class QuickInputList {
if (items.length > 0) {
const focused = this.list.getFocus()[0];
if (typeof focused === 'number') {
this.list.reveal(focused, 0, 0, true);
if (this.list.firstVisibleIndex <= focused && focused <= this.list.lastVisibleIndex) {
this.list.reveal(focused);
} else {
this.list.reveal(focused, 0);
}
}
}
}
Expand Down

0 comments on commit f7f0921

Please sign in to comment.