Skip to content

Conversation

@cwebster-99
Copy link
Member

No description provided.

Copy link
Contributor

Copilot AI left a 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 SettingsTreeFilter to support group filtering with a new filterGroups parameter
  • 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:

  1. Preventing deselection in paginated mode (always keep a category selected)
  2. Defaulting to the first category when deselection occurs in paginated mode
  3. 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;
				}

Comment on lines +1708 to +1712
const firstCategory = this.settingsTreeModel.value.root.children[0];
if (firstCategory instanceof SettingsTreeGroupElement) {
this.viewState.filterToCategory = firstCategory;
this.tocTree.setFocus([firstCategory]);
this.tocTree.setSelection([firstCategory]);
Copy link

Copilot AI Feb 3, 2026

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.

Suggested change
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]);
}

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@rzhao271 rzhao271 left a 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>
@rzhao271 rzhao271 marked this pull request as ready for review February 4, 2026 00:56
@rzhao271 rzhao271 marked this pull request as draft February 4, 2026 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants