Skip to content

Commit

Permalink
Add single level of categorization #126089 (#126861)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzhao271 authored Sep 14, 2021
1 parent 254c5c7 commit 22c0c2c
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 23 deletions.
3 changes: 3 additions & 0 deletions src/vs/platform/extensions/common/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export interface IConfigurationProperty {
}

export interface IConfiguration {
id?: string,
order?: number,
title?: string,
properties: { [key: string]: IConfigurationProperty; };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@
padding-right: 24px;
overflow: visible;
}
.settings-editor > .settings-body .settings-tree-container .monaco-list-row .monaco-tl-contents.group-title {
max-width: min(100%, 1000px); /* Cut off title if too long for window */
}

.settings-editor > .settings-body > .settings-tree-container .settings-group-title-label,
.settings-editor > .settings-body > .settings-tree-container .setting-item-contents {
Expand Down Expand Up @@ -559,15 +562,17 @@
padding-left: 15px;
width: 100%;
position: relative;
overflow: hidden;
text-overflow: ellipsis;
}

.settings-editor > .settings-body > .settings-tree-container .settings-group-level-1 {
font-size: 24px;
.settings-editor > .settings-body > .settings-tree-container .settings-group-title-label.settings-group-level-1 {
font-size: 26px;
}

.settings-editor > .settings-body > .settings-tree-container .settings-group-level-2 {
padding-top: 32px;
font-size: 20px;
.settings-editor > .settings-body > .settings-tree-container .settings-group-title-label.settings-group-level-2 {
font-size: 22px;
}
.settings-editor > .settings-body > .settings-tree-container .settings-group-title-label.settings-group-level-3 {
font-size: 18px;
}

.settings-editor.search-mode > .settings-body .settings-toc-container .monaco-list-row .settings-toc-count {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { preferencesClearInputIcon } from 'vs/workbench/contrib/preferences/brow
import { IWorkspaceTrustManagementService } from 'vs/platform/workspace/common/workspaceTrust';
import { IWorkbenchConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/textResourceConfigurationService';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';

export const enum SettingsFocusContext {
Search,
Expand Down Expand Up @@ -199,7 +200,8 @@ export class SettingsEditor2 extends EditorPane {
@IEditorGroupsService protected editorGroupService: IEditorGroupsService,
@IUserDataSyncWorkbenchService private readonly userDataSyncWorkbenchService: IUserDataSyncWorkbenchService,
@IUserDataAutoSyncEnablementService private readonly userDataAutoSyncEnablementService: IUserDataAutoSyncEnablementService,
@IWorkspaceTrustManagementService private readonly workspaceTrustManagementService: IWorkspaceTrustManagementService
@IWorkspaceTrustManagementService private readonly workspaceTrustManagementService: IWorkspaceTrustManagementService,
@IExtensionService private readonly extensionService: IExtensionService
) {
super(SettingsEditor2.ID, telemetryService, themeService, storageService);
this.delayedFilterLogging = new Delayer<void>(1000);
Expand Down Expand Up @@ -307,7 +309,7 @@ export class SettingsEditor2 extends EditorPane {
this.modelDisposables.clear();
this.modelDisposables.add(model.onDidChangeGroups(() => {
this.updatedConfigSchemaDelayer.trigger(() => {
this.onConfigUpdate(undefined, undefined, true);
this.onConfigUpdate(undefined, false, true);
});
}));
this.defaultSettingsEditorModel = model;
Expand Down Expand Up @@ -1025,7 +1027,7 @@ export class SettingsEditor2 extends EditorPane {
const commonlyUsed = resolveSettingsTree(commonlyUsedData, dividedGroups.core, this.logService);
resolvedSettingsRoot.children!.unshift(commonlyUsed.tree);

resolvedSettingsRoot.children!.push(resolveExtensionsSettings(dividedGroups.extension || []));
resolvedSettingsRoot.children!.push(await resolveExtensionsSettings(this.extensionService, dividedGroups.extension || []));

if (!this.workspaceTrustManagementService.isWorkspaceTrusted() && (this.viewState.settingsTarget instanceof URI || this.viewState.settingsTarget === ConfigurationTarget.WORKSPACE)) {
const configuredUntrustedWorkspaceSettings = resolveConfiguredUntrustedSettings(groups, this.viewState.settingsTarget, this.configurationService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { localize } from 'vs/nls';
export interface ITOCEntry<T> {
id: string;
label: string;
order?: number;
children?: ITOCEntry<T>[];
settings?: Array<T>;
}
Expand Down
63 changes: 53 additions & 10 deletions src/vs/workbench/contrib/preferences/browser/settingsTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import { settingsMoreActionIcon } from 'vs/workbench/contrib/preferences/browser
import { IWorkbenchConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { SettingsTarget } from 'vs/workbench/contrib/preferences/browser/preferencesWidgets';
import { MarkdownRenderer } from 'vs/editor/browser/core/markdownRenderer';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';

const $ = DOM.$;

Expand Down Expand Up @@ -358,27 +359,69 @@ export function resolveConfiguredUntrustedSettings(groups: ISettingsGroup[], tar
return [...allSettings].filter(setting => setting.restricted && inspectSetting(setting.key, target, configurationService).isConfigured);
}

export function resolveExtensionsSettings(groups: ISettingsGroup[]): ITOCEntry<ISetting> {
const settingsGroupToEntry = (group: ISettingsGroup) => {
export async function resolveExtensionsSettings(extensionService: IExtensionService, groups: ISettingsGroup[]): Promise<ITOCEntry<ISetting>> {
const extGroupTree = new Map<string, ITOCEntry<ISetting>>();
const addEntryToTree = (extensionId: string, extensionName: string, childEntry: ITOCEntry<ISetting>) => {
if (!extGroupTree.has(extensionId)) {
const rootEntry = {
id: extensionId,
label: extensionName,
children: []
};
extGroupTree.set(extensionId, rootEntry);
}
extGroupTree.get(extensionId)!.children!.push(childEntry);
};
const processGroupEntry = async (group: ISettingsGroup) => {
const flatSettings = arrays.flatten(
group.sections.map(section => section.settings));

return {
const extensionId = group.extensionInfo!.id;
const extension = await extensionService.getExtension(extensionId);
const extensionName = extension!.displayName ?? extension!.name;

const childEntry = {
id: group.id,
label: group.title,
order: group.order,
settings: flatSettings
};
addEntryToTree(extensionId, extensionName, childEntry);
};

const extGroups = groups
const processPromises = groups
.sort((a, b) => a.title.localeCompare(b.title))
.map(g => settingsGroupToEntry(g));
.map(g => processGroupEntry(g));

return Promise.all(processPromises).then(() => {
const extGroups: ITOCEntry<ISetting>[] = [];
for (const value of extGroupTree.values()) {
if (value.children!.length === 1) {
// push a flattened setting
extGroups.push({
id: value.id,
label: value.children![0].label,
settings: value.children![0].settings
});
} else {
value.children!.sort((a, b) => {
if (a.order !== undefined && b.order !== undefined) {
return a.order - b.order;
} else {
// leave things as-is
return 0;
}
});
extGroups.push(value);
}
}

return {
id: 'extensions',
label: localize('extensions', "Extensions"),
children: extGroups
};
return {
id: 'extensions',
label: localize('extensions', "Extensions"),
children: extGroups
};
});
}

function _resolveSettingsTree(tocData: ITOCEntry<string>, allSettings: Set<ISetting>, logService: ILogService): ITOCEntry<ISetting> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ export class SettingsTreeModel {
}

private createSettingsTreeGroupElement(tocEntry: ITOCEntry<ISetting>, parent?: SettingsTreeGroupElement): SettingsTreeGroupElement {

const depth = parent ? this.getDepth(parent) + 1 : 0;
const element = new SettingsTreeGroupElement(tocEntry.id, undefined, tocEntry.label, depth, false);
element.parent = parent;

const children: SettingsTreeGroupChild[] = [];
if (tocEntry.settings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface ISettingsGroup {
range: IRange;
title: string;
titleRange: IRange;
order: number;
sections: ISettingsSection[];
extensionInfo?: IConfigurationExtensionInfo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export class SettingsEditorModel extends AbstractSettingsModel implements ISetti
}],
title: modelGroup.title,
titleRange: modelGroup.titleRange,
order: modelGroup.order,
extensionInfo: modelGroup.extensionInfo
};
}
Expand Down Expand Up @@ -566,7 +567,7 @@ export class DefaultSettings extends Disposable {
if (!settingsGroup) {
settingsGroup = result.find(g => g.title === title && g.extensionInfo?.id === config.extensionInfo?.id);
if (!settingsGroup) {
settingsGroup = { sections: [{ settings: [] }], id: config.id || '', title: title || '', titleRange: nullRange, range: nullRange, extensionInfo: config.extensionInfo };
settingsGroup = { sections: [{ settings: [] }], id: config.id || '', title: title || '', titleRange: nullRange, order: config.order ?? 0, range: nullRange, extensionInfo: config.extensionInfo };
result.push(settingsGroup);
}
} else {
Expand All @@ -575,7 +576,7 @@ export class DefaultSettings extends Disposable {
}
if (config.properties) {
if (!settingsGroup) {
settingsGroup = { sections: [{ settings: [] }], id: config.id || '', title: config.id || '', titleRange: nullRange, range: nullRange, extensionInfo: config.extensionInfo };
settingsGroup = { sections: [{ settings: [] }], id: config.id || '', title: config.id || '', titleRange: nullRange, order: config.order ?? 0, range: nullRange, extensionInfo: config.extensionInfo };
result.push(settingsGroup);
}
const configurationSettings: ISetting[] = [];
Expand Down

0 comments on commit 22c0c2c

Please sign in to comment.