-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Add scroll behavior setting for Settings editor #292728
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?
Conversation
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 pull request adds a new scroll behavior setting (workbench.settings.scrollBehavior) for the Settings editor, allowing users to choose between two modes: 'paginated' (showing one category at a time) and 'continuous' (scrolling through all settings).
Changes:
- Added a new configuration setting with 'paginated' and 'continuous' enum values
- Refactored
SettingsTreeFilterto support group filtering with a newfilterGroupsparameter - Modified TOC focus change handler to apply filtering based on the selected scroll behavior mode
- Added logic to set an initial category when opening the editor in paginated mode
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/preferences/common/preferencesContribution.ts | Registers the new workbench.settings.scrollBehavior configuration setting with proper enum values and localized descriptions |
| src/vs/workbench/contrib/preferences/browser/tocTree.ts | Updates TOC tree filter instantiation to pass filterGroups: false since the TOC should show all categories |
| src/vs/workbench/contrib/preferences/browser/settingsTree.ts | Refactors filter logic to use parent traversal, adds group filtering support, and updates settings tree filter instantiation with filterGroups: true |
| src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts | Implements paginated vs continuous mode behavior in TOC focus handler, scroll sync, and initial state setup |
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts:1063
- In paginated mode, if the TOC tree selection is cleared (element is null), the settings tree would show nothing because filterToCategory is set to undefined. This could happen if a user deselects the current category in the TOC.
Consider either:
- Preventing deselection in paginated mode (always keep a category selected)
- Defaulting to the first category when deselection occurs in paginated mode
- Showing all settings when no category is selected (but this would defeat the purpose of paginated mode)
Option 1 seems most consistent with the paginated behavior design.
if (this.searchResultModel || scrollBehavior === 'paginated') {
// In search mode or paginated mode, filter to show only the selected category
if (this.viewState.filterToCategory !== element) {
this.viewState.filterToCategory = element ?? undefined;
// Force render in this case, because
// onDidClickSetting relies on the updated view.
this.renderTree(undefined, true);
this.settingsTree.scrollTop = 0;
}
src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts
Outdated
Show resolved
Hide resolved
| const firstCategory = this.settingsTreeModel.value.root.children[0]; | ||
| if (firstCategory instanceof SettingsTreeGroupElement) { | ||
| this.viewState.filterToCategory = firstCategory; | ||
| this.tocTree.setFocus([firstCategory]); | ||
| this.tocTree.setSelection([firstCategory]); |
Copilot
AI
Feb 3, 2026
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 code assumes that the settings tree model has at least one child category, but there's no safety check before accessing root.children[0]. If the settings model is empty or malformed for any reason, this would cause an error.
Consider adding a check to ensure root.children exists and has at least one element before attempting to access it.
| const firstCategory = this.settingsTreeModel.value.root.children[0]; | |
| if (firstCategory instanceof SettingsTreeGroupElement) { | |
| this.viewState.filterToCategory = firstCategory; | |
| this.tocTree.setFocus([firstCategory]); | |
| this.tocTree.setSelection([firstCategory]); | |
| const rootChildren = this.settingsTreeModel.value.root.children; | |
| if (Array.isArray(rootChildren) && rootChildren.length > 0) { | |
| const firstCategory = rootChildren[0]; | |
| if (firstCategory instanceof SettingsTreeGroupElement) { | |
| this.viewState.filterToCategory = firstCategory; | |
| this.tocTree.setFocus([firstCategory]); | |
| this.tocTree.setSelection([firstCategory]); | |
| } |
rzhao271
left a comment
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.
Toggling PR status to test microsoft/vscode-pull-request-github#8469
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.