-
Notifications
You must be signed in to change notification settings - Fork 37k
Implement autoscroll in ListView #284652
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
base: main
Are you sure you want to change the base?
Implement autoscroll in ListView #284652
Conversation
Fix #274428, hopefully
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.
Pull request overview
This PR implements autoscroll functionality directly in the ListView component to address issue #274428, eliminating the need for custom scroll management logic in consumers like ChatWidget.
Key changes:
- Added a new
autoscrolloption to ListView that automatically keeps the list scrolled to the bottom when content changes (height updates or splices), if the list was already at the bottom - Removed ChatWidget's custom scroll tracking logic including
previousTreeScrollHeight,scrollAnimationFrameDisposable, and the manual scroll-to-bottom logic inonDidChangeTreeContentHeight() - Added comprehensive test coverage for the autoscroll feature including edge cases
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/vs/base/browser/ui/list/listView.ts | Implements core autoscroll logic with isScrolledToBottom() method and autoscroll checks in updateElementHeight() and _splice() methods; adds autoscroll option to interfaces |
| src/vs/base/browser/ui/tree/abstractTree.ts | Adds autoscroll option to tree options interface to enable propagation through the tree abstraction layer |
| src/vs/workbench/contrib/chat/browser/chatWidget.ts | Removes custom scroll logic and enables the new autoscroll option; cleans up scrollAnimationFrameDisposable and previousTreeScrollHeight state |
| src/vs/base/test/browser/ui/list/listView.test.ts | Adds three comprehensive tests covering autoscroll behavior on element height changes, splices, and non-interference when not at bottom |
| } | ||
|
|
||
| private isScrolledToBottom(): boolean { | ||
| return this.scrollTop + this.renderHeight >= this.scrollHeight; |
Copilot
AI
Dec 21, 2025
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 isScrolledToBottom() method doesn't account for rounding errors. Due to rounding, the scrollTop + renderHeight will not exactly match the scrollHeight. This issue was documented in the old ChatWidget implementation that was removed (which used a 2px tolerance), and the same tolerance is still used elsewhere in the codebase.
For reference:
- The old ChatWidget code (removed in this PR) had:
this.tree.scrollTop + this.tree.renderHeight >= this.previousTreeScrollHeight - 2 - The debug REPL still uses:
tree.scrollTop + tree.renderHeight >= this.previousTreeScrollHeight - 2(see src/vs/workbench/contrib/debug/browser/repl.ts:691) - The ChatWidget still uses 2px tolerance for scroll-down button visibility:
this.tree.scrollTop >= this.tree.scrollHeight - this.tree.renderHeight - 2(line 1578)
Consider changing this to: return this.scrollTop + this.renderHeight >= this.scrollHeight - 2; to maintain consistency with existing scroll detection logic in the codebase.
| return this.scrollTop + this.renderHeight >= this.scrollHeight; | |
| return this.scrollTop + this.renderHeight >= this.scrollHeight - 2; |
Hopefully fix #274428
Do you think this makes sense in the ListView @joaomoreno @rebornix? It doesn't have to be, I just thought it's maybe easier and I wouldn't mind having a way for the copilot debug tree to auto-scroll down too at some point.