Skip to content

Commit

Permalink
Fix list.focusPageUp movement with `workbench.tree.enableStickyScro…
Browse files Browse the repository at this point in the history
…ll` (#202361)

fix #202288
  • Loading branch information
benibenj authored Jan 12, 2024
1 parent ab2a8a0 commit ce962df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/vs/base/browser/ui/list/listWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1762,9 +1762,10 @@ export class List<T> implements ISpliceable<T>, IDisposable {
}
}

async focusPreviousPage(browserEvent?: UIEvent, filter?: (element: T) => boolean): Promise<void> {
async focusPreviousPage(browserEvent?: UIEvent, filter?: (element: T) => boolean, getPaddingTop: () => number = () => 0): Promise<void> {
let firstPageIndex: number;
const scrollTop = this.view.getScrollTop();
const paddingTop = getPaddingTop();
const scrollTop = this.view.getScrollTop() + paddingTop;

if (scrollTop === 0) {
firstPageIndex = this.view.indexAt(scrollTop);
Expand All @@ -1784,14 +1785,14 @@ export class List<T> implements ISpliceable<T>, IDisposable {
}
} else {
const previousScrollTop = scrollTop;
this.view.setScrollTop(scrollTop - this.view.renderHeight);
this.view.setScrollTop(scrollTop - this.view.renderHeight - paddingTop);

if (this.view.getScrollTop() !== previousScrollTop) {
if (this.view.getScrollTop() + getPaddingTop() !== previousScrollTop) {
this.setFocus([]);

// Let the scroll event listener run
await timeout(0);
await this.focusPreviousPage(browserEvent, filter);
await this.focusPreviousPage(browserEvent, filter, getPaddingTop);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/tree/abstractTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2880,7 +2880,7 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
}

focusPreviousPage(browserEvent?: UIEvent, filter = (isKeyboardEvent(browserEvent) && browserEvent.altKey) ? undefined : this.focusNavigationFilter): Promise<void> {
return this.view.focusPreviousPage(browserEvent, filter);
return this.view.focusPreviousPage(browserEvent, filter, () => this.stickyScrollController?.height ?? 0);
}

focusLast(browserEvent?: UIEvent, filter = (isKeyboardEvent(browserEvent) && browserEvent.altKey) ? undefined : this.focusNavigationFilter): void {
Expand Down

0 comments on commit ce962df

Please sign in to comment.