Skip to content

Commit caf838e

Browse files
committed
1 parent 0ae3b97 commit caf838e

17 files changed

Lines changed: 170 additions & 291 deletions

File tree

src/vs/editor/common/config/commonEditorConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ export const editorConfigurationBaseNode = Object.freeze<IConfigurationNode>({
432432
order: 5,
433433
type: 'object',
434434
title: nls.localize('editorConfigurationTitle', "Editor"),
435-
scope: ConfigurationScope.RESOURCE_LANGUAGE,
435+
scope: ConfigurationScope.LANGUAGE_OVERRIDABLE,
436436
});
437437

438438
const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);

src/vs/editor/contrib/rename/rename.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfigurat
341341
id: 'editor',
342342
properties: {
343343
'editor.rename.enablePreview': {
344-
scope: ConfigurationScope.RESOURCE_LANGUAGE,
344+
scope: ConfigurationScope.LANGUAGE_OVERRIDABLE,
345345
description: nls.localize('enablePreview', "Enable/disable the ability to preview changes before renaming"),
346346
default: true,
347347
type: 'boolean'

src/vs/platform/configuration/common/configurationRegistry.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ export const enum ConfigurationScope {
100100
*/
101101
RESOURCE,
102102
/**
103-
* Resource specific configuration that can also be configured in language specific settings
103+
* Resource specific configuration that can be configured in language specific settings
104104
*/
105-
RESOURCE_LANGUAGE,
105+
LANGUAGE_OVERRIDABLE,
106106
/**
107107
* Machine specific configuration that can also be configured in workspace or folder settings.
108108
*/
@@ -221,7 +221,7 @@ class ConfigurationRegistry implements IConfigurationRegistry {
221221
delete windowSettings.properties[key];
222222
break;
223223
case ConfigurationScope.RESOURCE:
224-
case ConfigurationScope.RESOURCE_LANGUAGE:
224+
case ConfigurationScope.LANGUAGE_OVERRIDABLE:
225225
delete resourceSettings.properties[key];
226226
break;
227227
}
@@ -373,7 +373,7 @@ class ConfigurationRegistry implements IConfigurationRegistry {
373373
case ConfigurationScope.RESOURCE:
374374
resourceSettings.properties[key] = properties[key];
375375
break;
376-
case ConfigurationScope.RESOURCE_LANGUAGE:
376+
case ConfigurationScope.LANGUAGE_OVERRIDABLE:
377377
resourceSettings.properties[key] = properties[key];
378378
this.resourceLanguageSettingsSchema.properties![key] = properties[key];
379379
break;

src/vs/vscode.d.ts

Lines changed: 91 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4240,24 +4240,60 @@ declare module 'vscode' {
42404240
/**
42414241
* Represents the configuration. It is a merged view of
42424242
*
4243-
* - Default configuration
4244-
* - Global configuration
4245-
* - Workspace configuration (if available)
4246-
* - Workspace folder configuration of the requested resource (if available)
4243+
* - *Default Settings*
4244+
* - *Global (User) Settings*
4245+
* - *Workspace settings*
4246+
* - *Workspace Folder settings* - From one of the [Workspace Folders](#workspace.workspaceFolders) under which requested resource belongs to.
4247+
* - *Language settings* - Settings defined under requested language.
42474248
*
4248-
* *Global configuration* comes from User Settings and overrides Defaults.
4249+
* The *effective* value (returned by [`get`](#WorkspaceConfiguration.get)) is computed by overriding or merging the values in the following order.
42494250
*
4250-
* *Workspace configuration* comes from Workspace Settings and overrides Global configuration.
4251+
* ```
4252+
* `defaultValue`
4253+
* `globalValue` (if defined)
4254+
* `workspaceValue` (if defined)
4255+
* `workspaceFolderValue` (if defined)
4256+
* `defaultLanguageValue` (if defined)
4257+
* `globalLanguageValue` (if defined)
4258+
* `workspaceLanguageValue` (if defined)
4259+
* `workspaceLanguageValue` (if defined)
4260+
* ```
4261+
* **Note:** Only `object` value types are merged and all other value types are overridden.
4262+
*
4263+
* Example 1: Overriding
4264+
*
4265+
* ```ts
4266+
* defaultValue = 'on';
4267+
* globalValue = 'relative'
4268+
* workspaceFolderValue = 'off'
4269+
* value = 'off'
4270+
* ```
42514271
*
4252-
* *Workspace Folder configuration* comes from `.vscode` folder under one of the [workspace folders](#workspace.workspaceFolders) and overrides Workspace configuration.
4272+
* Example 2: Language Values
4273+
*
4274+
* ```ts
4275+
* defaultValue = 'on';
4276+
* globalValue = 'relative'
4277+
* workspaceFolderValue = 'off'
4278+
* globalLanguageValue = 'on'
4279+
* value = 'on'
4280+
* ```
4281+
*
4282+
* Example 3: Object Values
4283+
*
4284+
* ```ts
4285+
* defaultValue = { "a": 1, "b": 2 };
4286+
* globalValue = { "b": 3, "c": 4 };
4287+
* value = { "a": 1, "b": 3, "c": 4 };
4288+
* ```
42534289
*
42544290
* *Note:* Workspace and Workspace Folder configurations contains `launch` and `tasks` settings. Their basename will be
42554291
* part of the section identifier. The following snippets shows how to retrieve all configurations
42564292
* from `launch.json`:
42574293
*
42584294
* ```ts
42594295
* // launch.json configuration
4260-
* const config = workspace.getConfiguration('launch', vscode.window.activeTextEditor.document.uri);
4296+
* const config = workspace.getConfiguration('launch', vscode.workspace.workspaceFolders[0].uri);
42614297
*
42624298
* // retrieve values
42634299
* const values = config.get('configurations');
@@ -4295,57 +4331,64 @@ declare module 'vscode' {
42954331
/**
42964332
* Retrieve all information about a configuration setting. A configuration value
42974333
* often consists of a *default* value, a global or installation-wide value,
4298-
* a workspace-specific value and a folder-specific value.
4334+
* a workspace-specific value, folder-specific value
4335+
* and language-specific values (if [WorkspaceConfiguration](#WorkspaceConfiguration) is scoped to a language).
42994336
*
4300-
* The *effective* value (returned by [`get`](#WorkspaceConfiguration.get))
4301-
* is computed like this: `defaultValue` overridden by `globalValue`,
4302-
* `globalValue` overridden by `workspaceValue`. `workspaceValue` overridden by `workspaceFolderValue`.
4303-
* Refer to [Settings](https://code.visualstudio.com/docs/getstarted/settings)
4304-
* for more information.
4337+
* Also provides all language ids under which the given configuration setting is defined.
43054338
*
43064339
* *Note:* The configuration name must denote a leaf in the configuration tree
43074340
* (`editor.fontSize` vs `editor`) otherwise no result is returned.
43084341
*
43094342
* @param section Configuration name, supports _dotted_ names.
43104343
* @return Information about a configuration setting or `undefined`.
43114344
*/
4312-
inspect<T>(section: string): { key: string; defaultValue?: T; globalValue?: T; workspaceValue?: T, workspaceFolderValue?: T } | undefined;
4345+
inspect<T>(section: string): {
4346+
key: string;
4347+
4348+
defaultValue?: T;
4349+
globalValue?: T;
4350+
workspaceValue?: T,
4351+
workspaceFolderValue?: T,
4352+
4353+
defaultLanguageValue?: T;
4354+
userLanguageValue?: T;
4355+
workspaceLanguageValue?: T;
4356+
workspaceFolderLanguageValue?: T;
4357+
4358+
languageIds?: string[];
4359+
4360+
} | undefined;
43134361

43144362
/**
43154363
* Update a configuration value. The updated configuration values are persisted.
43164364
*
43174365
* A value can be changed in
43184366
*
4319-
* - [Global configuration](#ConfigurationTarget.Global): Changes the value for all instances of the editor.
4320-
* - [Workspace configuration](#ConfigurationTarget.Workspace): Changes the value for current workspace, if available.
4321-
* - [Workspace folder configuration](#ConfigurationTarget.WorkspaceFolder): Changes the value for the
4322-
* [Workspace folder](#workspace.workspaceFolders) to which the current [configuration](#WorkspaceConfiguration) is scoped to.
4323-
*
4324-
* *Note 1:* Setting a global value in the presence of a more specific workspace value
4325-
* has no observable effect in that workspace, but in others. Setting a workspace value
4326-
* in the presence of a more specific folder value has no observable effect for the resources
4327-
* under respective [folder](#workspace.workspaceFolders), but in others. Refer to
4328-
* [Settings Inheritance](https://code.visualstudio.com/docs/getstarted/settings) for more information.
4329-
*
4330-
* *Note 2:* To remove a configuration value use `undefined`, like so: `config.update('somekey', undefined)`
4367+
* - [Global settings](#ConfigurationTarget.Global): Changes the value for all instances of the editor.
4368+
* - [Workspace settings](#ConfigurationTarget.Workspace): Changes the value for current workspace, if available.
4369+
* - [Workspace folder settings](#ConfigurationTarget.WorkspaceFolder): Changes the value for settings from one of the [Workspace Folders](#workspace.workspaceFolders) under which the requested resource belongs to.
4370+
* - Language settings: Changes the value for the requested languageId.
43314371
*
4332-
* Will throw error when
4333-
* - Writing a configuration which is not registered.
4334-
* - Writing a configuration to workspace or folder target when no workspace is opened
4335-
* - Writing a configuration to folder target when there is no folder settings
4336-
* - Writing to folder target without passing a resource when getting the configuration (`workspace.getConfiguration(section, resource)`)
4337-
* - Writing a window configuration to folder target
4372+
* *Note:* To remove a configuration value use `undefined`, like so: `config.update('somekey', undefined)`
43384373
*
43394374
* @param section Configuration name, supports _dotted_ names.
43404375
* @param value The new value.
43414376
* @param configurationTarget The [configuration target](#ConfigurationTarget) or a boolean value.
4342-
* - If `true` configuration target is `ConfigurationTarget.Global`.
4343-
* - If `false` configuration target is `ConfigurationTarget.Workspace`.
4344-
* - If `undefined` or `null` configuration target is
4345-
* `ConfigurationTarget.WorkspaceFolder` when configuration is resource specific
4346-
* `ConfigurationTarget.Workspace` otherwise.
4347-
*/
4348-
update(section: string, value: any, configurationTarget?: ConfigurationTarget | boolean): Thenable<void>;
4377+
* - If `true` updates [Global settings](#ConfigurationTarget.Global).
4378+
* - If `false` updates [Workspace settings](#ConfigurationTarget.Workspace).
4379+
* - If `undefined` or `null` updates to [Workspace folder settings](#ConfigurationTarget.WorkspaceFolder) if configuration is resource specific,
4380+
* otherwise to [Workspace settings](#ConfigurationTarget.Workspace).
4381+
* @param scopeToLanguage Whether to update the value in the scope of requested languageId or not.
4382+
* - If `true` updates the value under the requested languageId.
4383+
* - If `undefined` updates the value under the requested languageId only if the configuration is defined for the language.
4384+
* @throws error while updating
4385+
* - configuration which is not registered.
4386+
* - window configuration to workspace folder
4387+
* - configuration to workspace or workspace folder when no workspace is opened.
4388+
* - configuration to workspace folder when there is no workspace folder settings.
4389+
* - configuration to workspace folder when [WorkspaceConfiguration](#WorkspaceConfiguration) is not scoped to a resource.
4390+
*/
4391+
update(section: string, value: any, configurationTarget?: ConfigurationTarget | boolean, scopeToLanguage?: boolean): Thenable<void>;
43494392

43504393
/**
43514394
* Readable dictionary that backs this configuration.
@@ -8692,13 +8735,12 @@ declare module 'vscode' {
86928735
* is returned. Dots in the section-identifier are interpreted as child-access,
86938736
* like `{ myExt: { setting: { doIt: true }}}` and `getConfiguration('myExt.setting').get('doIt') === true`.
86948737
*
8695-
* When a resource is provided, configuration scoped to that resource is returned.
8738+
* When a scope is provided configuraiton confined to that scope is returned. Scope can be a resource or a language identifier or both.
86968739
*
86978740
* @param section A dot-separated identifier.
8698-
* @param resource A resource for which the configuration is asked for
86998741
* @return The full configuration or a subset.
87008742
*/
8701-
export function getConfiguration(section?: string, resource?: Uri | null): WorkspaceConfiguration;
8743+
export function getConfiguration(section?: string | undefined, scope?: ConfigurationScope | null): WorkspaceConfiguration;
87028744

87038745
/**
87048746
* An event that is emitted when the [configuration](#WorkspaceConfiguration) changed.
@@ -8730,19 +8772,21 @@ declare module 'vscode' {
87308772
export function registerFileSystemProvider(scheme: string, provider: FileSystemProvider, options?: { readonly isCaseSensitive?: boolean, readonly isReadonly?: boolean }): Disposable;
87318773
}
87328774

8775+
export type ConfigurationScope = Uri | TextDocument | WorkspaceFolder | { uri?: Uri, languageId: string };
8776+
87338777
/**
87348778
* An event describing the change in Configuration
87358779
*/
87368780
export interface ConfigurationChangeEvent {
87378781

87388782
/**
8739-
* Returns `true` if the given section for the given resource (if provided) is affected.
8783+
* Returns `true` if the given section is affected in the provided scope.
87408784
*
87418785
* @param section Configuration name, supports _dotted_ names.
8742-
* @param resource A resource Uri.
8743-
* @return `true` if the given section for the given resource (if provided) is affected.
8786+
* @param scope A scope in which to check.
8787+
* @return `true` if the given section is affected in the provided scope.
87448788
*/
8745-
affectsConfiguration(section: string, resource?: Uri): boolean;
8789+
affectsConfiguration(section: string, scope?: ConfigurationScope): boolean;
87468790
}
87478791

87488792
/**

0 commit comments

Comments
 (0)