-
Notifications
You must be signed in to change notification settings - Fork 34.6k
Added cachedScrollTop
to SCM panel
#74723
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
Conversation
The first commit seemed illogical since it was handling rendering concerns (scrollbar position) outside the More that that, when the user resizes the sidebar, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix might be much simpler than this. Other viewlets keep their scroll position as they come and go, and they don't save any scroll top. We have to see why SCM is different and fix that instead.
Let me check then. |
The SCM viewletAs I discovered, other viewlets virtually do nothing to keep their scroll position. Actually, the unique behavior of the repository panel ( private onDidChangeVisibility(visible: boolean): void {
if (visible) {
const listSplicer = new ResourceGroupSplicer(this.repository.provider.groups, this.list);
this.visibilityDisposables.push(listSplicer);
} else {
this.visibilityDisposables = dispose(this.visibilityDisposables);
}
} Note that the dispose(): void {
this.onDidSpliceGroups({ start: 0, deleteCount: this.items.length, toInsert: [] });
this.disposables = dispose(this.disposables);
} Therefore, it's quite normal for the list to reset the scroll position to the top since all its items are removed. In other words, it's not losing any view state. Other viewlets do not clear their list/tree items, so their view state is retained throughout the entire application's life cycle. Retaining itemsTo verify this, I changed the event handler above to the one below so as to avoid disposing of visuals: private isCreatedOnce = false;
private onDidChangeVisibility(visible: boolean): void {
if (!isCreatedOnce && visible) {
const listSplicer = new ResourceGroupSplicer(this.repository.provider.groups, this.list);
this.visibilityDisposables.push(listSplicer);
this.isCreatedOnce = true;
}
} and it did keep the scroll position from resetting. Another instanceThe Outline view (tree), too, disposes of visual elements but since the data trees provide their view state, which merely contains selections and expanded/collapsed state of the tree items (not the scroll position), once revealed, the viewlet retrieves the last view state and seems to retain the scroll position. But when there's no selected item, the Outline viewlet scroll keeps reseting to the top. TL;DRAt this moment, I see these solutions:
IMO, the second solution needs further study as to discover why it was decided at first to remove the list items. The third solution requires design-level decisions on, presuming it being acceptable, what view state parameters to expose and how it should be done. So, I'm still left with the first choice. |
Absolutely agree. Great investigation! 👏 We'll take it, thanks! 🍻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
Thank you for making me go for that. 👍 |
Fixes #73622
Added the new private property
cachedScrollTop
(toRepositoryPanel
) to hold the vertical scrollbar position when its visibility changes.