Skip to content

Commit 1cc507a

Browse files
committed
Revert changes in listWidget and instead pass different arguments in quickInputList
1 parent 4c08209 commit 1cc507a

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

src/vs/base/browser/ui/list/listWidget.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,7 +1865,7 @@ export class List<T> implements ISpliceable<T>, IDisposable {
18651865
return this.getFocus().map(i => this.view.element(i));
18661866
}
18671867

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

18771877
if (isNumber(relativeTop)) {
1878-
let applyRelativeTop: boolean;
1879-
if (applyRelativeTopOnlyIfNotVisible) {
1880-
const viewItemBottom = elementTop + elementHeight;
1881-
const scrollBottom = scrollTop + this.view.renderHeight;
1882-
1883-
applyRelativeTop = elementTop < scrollTop + paddingTop || viewItemBottom >= scrollBottom;
1884-
} else {
1885-
applyRelativeTop = true;
1886-
}
1887-
if (applyRelativeTop) {
1888-
// y = mx + b
1889-
const m = elementHeight - this.view.renderHeight + paddingTop;
1890-
this.view.setScrollTop(m * clamp(relativeTop, 0, 1) + elementTop - paddingTop);
1891-
}
1878+
// y = mx + b
1879+
const m = elementHeight - this.view.renderHeight + paddingTop;
1880+
this.view.setScrollTop(m * clamp(relativeTop, 0, 1) + elementTop - paddingTop);
18921881
} else {
18931882
const viewItemBottom = elementTop + elementHeight;
18941883
const scrollBottom = scrollTop + this.view.renderHeight;

src/vs/platform/quickinput/browser/quickInputList.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,11 @@ export class QuickInputList {
717717
if (items.length > 0) {
718718
const focused = this.list.getFocus()[0];
719719
if (typeof focused === 'number') {
720-
this.list.reveal(focused, 0, 0, true);
720+
if (this.list.firstVisibleIndex <= focused && focused <= this.list.lastVisibleIndex) {
721+
this.list.reveal(focused);
722+
} else {
723+
this.list.reveal(focused, 0);
724+
}
721725
}
722726
}
723727
}

0 commit comments

Comments
 (0)