src/vs/workbench/services/preferences/common/preferences.ts

355 LOC · 346 covered · 9 uncovered · 2 ranges · 18 concepts · 1 introducers · 11 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the fileexternalUriOpenerService.ts ×2 · 4 introduced LOCexternalUriOpenerService…externalUriOpenerService.ts ×1 · 2 introduced LOCexternalUriOpenerService…externalUriOpenerService.ts ×9 · 38 introduced LOCexternalUriOpenerService…externalUriOpenerService.ts ×2 · 3 introduced LOCexternalUriOpenerService…externalUriOpenerService.ts ×9 · 172 introduced LOCexternalUriOpenerService…preferencesModels.ts ×2 · 4 introduced LOCpreferencesModels.ts ×2preferencesModels.test|title=DefaultSettings separates groups with same id but different titles|occurrence=1, preferencesModels.test|title=DefaultSettings groups settings correctly when extension id is same as group id|occurrence=1 · 0 introduced LOCpreferencesModels.test|t…preferencesModels.ts ×2 · 2 introduced LOCpreferencesModels.ts ×2preferencesModels.test|title=DefaultSettings groups settings by title when they share the same extension id|occurrence=1 · 0 introduced LOCpreferencesModels.test|t…preferencesModels.ts ×2 · 6 introduced LOCpreferencesModels.ts ×2preferencesModels.ts ×1 · 1 introduced LOCpreferencesModels.ts ×1preferencesModels.ts ×2 · 7 introduced LOCpreferencesModels.ts ×2preferencesModels.ts ×1 · 2 introduced LOCpreferencesModels.ts ×1preferencesModels.ts ×3 · 3 introduced LOCpreferencesModels.ts ×3preferencesModels.ts ×2 · 3 introduced LOCpreferencesModels.ts ×2preferencesModels.ts ×1 · 3 introduced LOCpreferencesModels.ts ×1preferencesModels.ts ×90 · 441 introduced LOCpreferencesModels.ts ×90preferences.ts ×2 · 346 introduced LOCpreferences.ts ×2externalUriOpenerService.test|title=ExternalUriOpenerService Should automatically pick single preferred opener without prompt|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/externalUriOpener/test/common/externalUriOpenerService.test|title=ExternalUriOpenerService Should automatically pick single preferred opener without prompt|occurrence=1externalUriOpenerService…externalUriOpenerService.test|title=ExternalUriOpenerService Should not open if there are no openers|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/externalUriOpener/test/common/externalUriOpenerService.test|title=ExternalUriOpenerService Should not open if there are no openers|occurrence=1externalUriOpenerService…externalUriOpenerService.test|title=ExternalUriOpenerService Should prompt if there is at least one enabled opener|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/externalUriOpener/test/common/externalUriOpenerService.test|title=ExternalUriOpenerService Should prompt if there is at least one enabled opener|occurrence=1externalUriOpenerService…preferencesModels.test|title=DefaultSettings groups settings by id when they share the same extension id and have no title|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/preferences/test/common/preferencesModels.test|title=DefaultSettings groups settings by id when they share the same extension id and have no title|occurrence=1preferencesModels.test|t…preferencesModels.test|title=DefaultSettings groups settings by title when they share the same extension id|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/preferences/test/common/preferencesModels.test|title=DefaultSettings groups settings by title when they share the same extension id|occurrence=1preferencesModels.test|t…preferencesModels.test|title=DefaultSettings groups settings correctly when extension id is same as group id|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/preferences/test/common/preferencesModels.test|title=DefaultSettings groups settings correctly when extension id is same as group id|occurrence=1preferencesModels.test|t…preferencesModels.test|title=DefaultSettings merges untitled group into titled group if id matches|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/preferences/test/common/preferencesModels.test|title=DefaultSettings merges untitled group into titled group if id matches|occurrence=1preferencesModels.test|t…preferencesModels.test|title=DefaultSettings separates groups with same id (no title) but different extension ids|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/preferences/test/common/preferencesModels.test|title=DefaultSettings separates groups with same id (no title) but different extension ids|occurrence=1preferencesModels.test|t…preferencesModels.test|title=DefaultSettings separates groups with same id and title but different extension ids|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/preferences/test/common/preferencesModels.test|title=DefaultSettings separates groups with same id and title but different extension ids|occurrence=1preferencesModels.test|t…preferencesModels.test|title=DefaultSettings separates groups with same id but different titles|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/preferences/test/common/preferencesModels.test|title=DefaultSettings separates groups with same id but different titles|occurrence=1preferencesModels.test|t…preferencesModels.test|title=DefaultSettings sorts groups by order|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/services/preferences/test/common/preferencesModels.test|title=DefaultSettings sorts groups by order|occurrence=1preferencesModels.test|t…Focused file · src/vs/workbench/services/preferences/common/preferences.ts · 355 LOCcommon/preferences.ts

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- preferences.ts ×2
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { IStringDictionary } from '../../../../base/common/collections.js';
7 > import { Event } from '../../../../base/common/event.js';
8 > import { IMatch } from '../../../../base/common/filters.js';
9 > import { IJSONSchema, IJSONSchemaMap } from '../../../../base/common/jsonSchema.js';
10 > import { ResolvedKeybinding } from '../../../../base/common/keybindings.js';
11 > import { URI } from '../../../../base/common/uri.js';
12 > import { IRange } from '../../../../editor/common/core/range.js';
13 > import { IEditorContribution } from '../../../../editor/common/editorCommon.js';
14 > import { ConfigurationTarget } from '../../../../platform/configuration/common/configuration.js';
15 > import { ConfigurationDefaultValueSource, ConfigurationScope, EditPresentationTypes, IExtensionInfo } from '../../../../platform/configuration/common/configurationRegistry.js';
16 > import { IEditorOptions } from '../../../../platform/editor/common/editor.js';
17 > import { IExtensionDescription } from '../../../../platform/extensions/common/extensions.js';
18 > import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
19 > import { ResolvedKeybindingItem } from '../../../../platform/keybinding/common/resolvedKeybindingItem.js';
20 > import { DEFAULT_EDITOR_ASSOCIATION, IEditorPane } from '../../../common/editor.js';
21 > import { EditorInput } from '../../../common/editor/editorInput.js';
22 > import { Settings2EditorModel } from './preferencesModels.js';
23 >
24 > export enum SettingValueType {
25 > Null = 'null',
26 > Enum = 'enum',
27 > String = 'string',
28 > MultilineString = 'multiline-string',
29 > Integer = 'integer',
30 > Number = 'number',
31 > Boolean = 'boolean',
32 > Array = 'array',
33 > Exclude = 'exclude',
34 > Include = 'include',
35 > Complex = 'complex',
36 > NullableInteger = 'nullable-integer',
37 > NullableNumber = 'nullable-number',
38 > Object = 'object',
39 > BooleanObject = 'boolean-object',
40 > LanguageTag = 'language-tag',
41 > ExtensionToggle = 'extension-toggle',
42 > ComplexObject = 'complex-object',
43 > }
44 >
45 > export interface ISettingsGroup {
46 > id: string;
47 > range: IRange;
48 > title: string;
49 > titleRange: IRange;
50 > sections: ISettingsSection[];
51 > order?: number;
52 > extensionInfo?: IExtensionInfo;
53 > }
54 >
55 > export interface ISettingsSection {
56 > title?: string;
57 > settings: ISetting[];
58 > }
59 >
60 > export interface ISetting {
61 > range: IRange;
62 > key: string;
63 > keyRange: IRange;
64 > value: any;
65 > valueRange: IRange;
66 > description: string[];
67 > keywords?: string[];
68 > descriptionIsMarkdown?: boolean;
69 > descriptionRanges: IRange[];
70 > overrides?: ISetting[];
71 > overrideOf?: ISetting;
72 > deprecationMessage?: string;
73 > deprecationMessageIsMarkdown?: boolean;
74 >
75 > scope?: ConfigurationScope;
76 > type?: string | string[];
77 > order?: number;
78 > arrayItemType?: string;
79 > objectProperties?: IJSONSchemaMap;
80 > objectPatternProperties?: IJSONSchemaMap;
81 > objectAdditionalProperties?: boolean | IJSONSchema;
82 > propertyNames?: IJSONSchema;
83 > enum?: string[];
84 > enumDescriptions?: string[];
85 > enumDescriptionsAreMarkdown?: boolean;
86 > uniqueItems?: boolean;
87 > tags?: string[];
88 > disallowSyncIgnore?: boolean;
89 > restricted?: boolean;
90 > extensionInfo?: IExtensionInfo;
91 > validator?: (value: any) => string | null;
92 > enumItemLabels?: string[];
93 > editPresentation?: EditPresentationTypes;
94 > nonLanguageSpecificDefaultValueSource?: ConfigurationDefaultValueSource;
95 > isLanguageTagSetting?: boolean;
96 > categoryLabel?: string;
97 >
98 > // Internal properties
99 > allKeysAreBoolean?: boolean;
100 > displayExtensionId?: string;
101 > title?: string;
102 > extensionGroupTitle?: string;
103 > internalOrder?: number;
104 > }
105 >
106 > export interface IExtensionSetting extends ISetting {
107 > extensionName?: string;
108 > extensionPublisher?: string;
109 > }
110 >
111 > export interface ISearchResult {
112 > filterMatches: ISettingMatch[];
113 > exactMatch: boolean;
114 > metadata?: IFilterMetadata;
115 > }
116 >
117 > export interface ISearchResultGroup {
118 > id: string;
119 > label: string;
120 > result: ISearchResult;
121 > order: number;
122 > }
123 >
124 > export interface IFilterResult {
125 > query?: string;
126 > filteredGroups: ISettingsGroup[];
127 > allGroups: ISettingsGroup[];
128 > matches: IRange[];
129 > metadata?: IStringDictionary<IFilterMetadata>;
130 > exactMatch?: boolean;
131 > }
132 >
133 > /**
134 > * The ways a setting could match a query,
135 > * sorted in increasing order of relevance.
136 > */
137 > export enum SettingMatchType {
138 > None = 0,
139 > LanguageTagSettingMatch = 1 << 0,
140 > RemoteMatch = 1 << 1,
141 > NonContiguousQueryInSettingId = 1 << 2,
142 > DescriptionOrValueMatch = 1 << 3,
143 > NonContiguousWordsInSettingsLabel = 1 << 4,
144 > ContiguousWordsInSettingsLabel = 1 << 5,
145 > ContiguousQueryInSettingId = 1 << 6,
146 > AllWordsInSettingsLabel = 1 << 7,
147 > ExactMatch = 1 << 8,
148 > }
149 > export const SettingKeyMatchTypes = (SettingMatchType.AllWordsInSettingsLabel
150 > | SettingMatchType.ContiguousWordsInSettingsLabel
151 > | SettingMatchType.NonContiguousWordsInSettingsLabel
152 > | SettingMatchType.NonContiguousQueryInSettingId
153 > | SettingMatchType.ContiguousQueryInSettingId);
154 >
155 > export interface ISettingMatch {
156 > setting: ISetting;
157 > matches: IRange[] | null;
158 > matchType: SettingMatchType;
159 > keyMatchScore: number;
160 > score: number;
161 > providerName?: string;
162 > }
163 >
164 > export interface IScoredResults {
165 > [key: string]: IRemoteSetting;
166 > }
167 >
168 > export interface IRemoteSetting {
169 > score: number;
170 > key: string;
171 > id: string;
172 > defaultValue: string;
173 > description: string;
174 > packageId: string;
175 > extensionName?: string;
176 > extensionPublisher?: string;
177 > }
178 >
179 > export interface IFilterMetadata {
180 > requestUrl: string;
181 > requestBody: string;
182 > timestamp: number;
183 > duration: number;
184 > scoredResults: IScoredResults;
185 >
186 > /** The number of requests made, since requests are split by number of filters */
187 > requestCount?: number;
188 >
189 > /** The name of the server that actually served the request */
190 > context: string;
191 > }
192 >
193 > export interface IPreferencesEditorModel<T> {
194 > uri?: URI;
195 > getPreference(key: string): T | undefined;
196 > dispose(): void;
197 > }
198 >
199 > export type IGroupFilter = (group: ISettingsGroup) => boolean | null;
200 > export type ISettingMatcher = (setting: ISetting, group: ISettingsGroup) => { matches: IRange[]; matchType: SettingMatchType; keyMatchScore: number; score: number } | null;
201 >
202 > export interface ISettingsEditorModel extends IPreferencesEditorModel<ISetting> {
203 > readonly onDidChangeGroups: Event<void>;
204 > settingsGroups: ISettingsGroup[];
205 > filterSettings(filter: string, groupFilter: IGroupFilter, settingMatcher: ISettingMatcher): ISettingMatch[];
206 > updateResultGroup(id: string, resultGroup: ISearchResultGroup | undefined): IFilterResult | undefined;
207 > }
208 >
209 > export interface ISettingsEditorOptions extends IEditorOptions {
210 > target?: ConfigurationTarget;
211 > folderUri?: URI;
212 > query?: string;
213 > /**
214 > * Only works when opening the json settings file. Use `query` for settings editor.
215 > */
216 > revealSetting?: {
217 > key: string;
218 > edit?: boolean;
219 > };
220 > focusSearch?: boolean;
221 > }
222 >
223 > export interface IOpenSettingsOptions extends ISettingsEditorOptions {
224 > jsonEditor?: boolean;
225 > openToSide?: boolean;
226 > groupId?: number;
227 > }
228 >
229 > export function validateSettingsEditorOptions(options: ISettingsEditorOptions): ISettingsEditorOptions {
230 return {
231 // Inherit provided options
232 ...options,
233
234 // Enforce some options for settings specifically
235 override: DEFAULT_EDITOR_ASSOCIATION.id,
236 pinned: true
237 };
238 }
240 > export interface IKeybindingsEditorModel<T> extends IPreferencesEditorModel<T> {
241 > }
242 >
243 > export interface IKeybindingsEditorOptions extends IEditorOptions {
244 > query?: string;
245 > }
246 >
247 > export interface IOpenKeybindingsEditorOptions extends IKeybindingsEditorOptions {
248 > groupId?: number;
249 > }
250 >
251 > export const IPreferencesService = createDecorator<IPreferencesService>('preferencesService');
252 >
253 > export interface IPreferencesService {
254 > readonly _serviceBrand: undefined;
255 >
256 > readonly onDidDefaultSettingsContentChanged: Event<URI>;
257 >
258 > userSettingsResource: URI;
259 > workspaceSettingsResource: URI | null;
260 > getFolderSettingsResource(resource: URI): URI | null;
261 >
262 > createPreferencesEditorModel(uri: URI): Promise<IPreferencesEditorModel<ISetting> | null>;
263 > getDefaultSettingsContent(uri: URI): string | undefined;
264 > hasDefaultSettingsContent(uri: URI): boolean;
265 > createSettings2EditorModel(): Settings2EditorModel; // TODO
266 >
267 > openPreferences(): Promise<void>;
268 >
269 > openRawDefaultSettings(): Promise<IEditorPane | undefined>;
270 > openSettings(options?: IOpenSettingsOptions): Promise<IEditorPane | undefined>;
271 > openApplicationSettings(options?: IOpenSettingsOptions): Promise<IEditorPane | undefined>;
272 > openUserSettings(options?: IOpenSettingsOptions): Promise<IEditorPane | undefined>;
273 > openRemoteSettings(options?: IOpenSettingsOptions): Promise<IEditorPane | undefined>;
274 > openWorkspaceSettings(options?: IOpenSettingsOptions): Promise<IEditorPane | undefined>;
275 > openFolderSettings(options: IOpenSettingsOptions & { folderUri: IOpenSettingsOptions['folderUri'] }): Promise<IEditorPane | undefined>;
276 > openGlobalKeybindingSettings(textual: boolean, options?: IOpenKeybindingsEditorOptions): Promise<void>;
277 > openDefaultKeybindingsFile(): Promise<IEditorPane | undefined>;
278 > openLanguageSpecificSettings(languageId: string, options?: IOpenSettingsOptions): Promise<IEditorPane | undefined>;
279 > getEditableSettingsURI(configurationTarget: ConfigurationTarget, resource?: URI): Promise<URI | null>;
280 > getSetting(settingId: string): ISetting | undefined;
281 >
282 > createSplitJsonEditorInput(configurationTarget: ConfigurationTarget, resource: URI): EditorInput;
283 > }
284 >
285 > export interface KeybindingMatch {
286 > ctrlKey?: boolean;
287 > shiftKey?: boolean;
288 > altKey?: boolean;
289 > metaKey?: boolean;
290 > keyCode?: boolean;
291 > }
292 >
293 > export interface KeybindingMatches {
294 > firstPart: KeybindingMatch;
295 > chordPart: KeybindingMatch;
296 > }
297 >
298 > export interface IKeybindingItemEntry {
299 > id: string;
300 > templateId: string;
301 > keybindingItem: IKeybindingItem;
302 > commandIdMatches?: IMatch[];
303 > commandLabelMatches?: IMatch[];
304 > commandDefaultLabelMatches?: IMatch[];
305 > sourceMatches?: IMatch[];
306 > extensionIdMatches?: IMatch[];
307 > extensionLabelMatches?: IMatch[];
308 > whenMatches?: IMatch[];
309 > keybindingMatches?: KeybindingMatches;
310 > }
311 >
312 > export interface IKeybindingItem {
313 > keybinding: ResolvedKeybinding;
314 > keybindingItem: ResolvedKeybindingItem;
315 > commandLabel: string;
316 > commandDefaultLabel: string;
317 > command: string;
318 > source: string | IExtensionDescription;
319 > when: string;
320 > }
321 >
322 > export interface IKeybindingsEditorPane extends IEditorPane {
323 >
324 > readonly activeKeybindingEntry: IKeybindingItemEntry | null;
325 > readonly onDefineWhenExpression: Event<IKeybindingItemEntry>;
326 > readonly onLayout: Event<void>;
327 >
328 > search(filter: string): void;
329 > focusSearch(): void;
330 > clearSearchResults(): void;
331 > focusKeybindings(): void;
332 > recordSearchKeys(): void;
333 > toggleSortByPrecedence(): void;
334 > selectKeybinding(keybindingEntry: IKeybindingItemEntry): void;
335 > defineKeybinding(keybindingEntry: IKeybindingItemEntry, add: boolean): Promise<void>;
336 > defineWhenExpression(keybindingEntry: IKeybindingItemEntry): void;
337 > updateKeybinding(keybindingEntry: IKeybindingItemEntry, key: string, when: string | undefined): Promise<any>;
338 > removeKeybinding(keybindingEntry: IKeybindingItemEntry): Promise<any>;
339 > resetKeybinding(keybindingEntry: IKeybindingItemEntry): Promise<any>;
340 > copyKeybinding(keybindingEntry: IKeybindingItemEntry): Promise<void>;
341 > copyKeybindingCommand(keybindingEntry: IKeybindingItemEntry): Promise<void>;
342 > showSimilarKeybindings(keybindingEntry: IKeybindingItemEntry): void;
343 > }
344 >
345 > export const DEFINE_KEYBINDING_EDITOR_CONTRIB_ID = 'editor.contrib.defineKeybinding';
346 > export interface IDefineKeybindingEditorContribution extends IEditorContribution {
347 > showDefineKeybindingWidget(): void;
348 > }
349 >
350 > export const FOLDER_SETTINGS_PATH = '.vscode/settings.json';
351 > export const DEFAULT_SETTINGS_EDITOR_SETTING = 'workbench.settings.openDefaultSettings';
352 > export const USE_SPLIT_JSON_SETTING = 'workbench.settings.useSplitJSON';
353 > export const ALWAYS_SHOW_ADVANCED_SETTINGS_SETTING = 'workbench.settings.alwaysShowAdvancedSettings';
354 >
355 > export const SETTINGS_AUTHORITY = 'settings';