Merge pull request #109750 from microsoft/sandy081/fix109709
Merge configuration defaults of language overrides
This commit is contained in:
commit
7e25008c60
2 changed files with 55 additions and 1 deletions
|
@ -227,9 +227,9 @@ class ConfigurationRegistry implements IConfigurationRegistry {
|
|||
for (const defaultConfiguration of defaultConfigurations) {
|
||||
for (const key in defaultConfiguration) {
|
||||
properties.push(key);
|
||||
this.defaultValues[key] = defaultConfiguration[key];
|
||||
|
||||
if (OVERRIDE_PROPERTY_PATTERN.test(key)) {
|
||||
this.defaultValues[key] = { ...(this.defaultValues[key] || {}), ...defaultConfiguration[key] };
|
||||
const property: IConfigurationPropertySchema = {
|
||||
type: 'object',
|
||||
default: this.defaultValues[key],
|
||||
|
@ -240,6 +240,7 @@ class ConfigurationRegistry implements IConfigurationRegistry {
|
|||
this.configurationProperties[key] = property;
|
||||
this.defaultLanguageConfigurationOverridesNode.properties![key] = property;
|
||||
} else {
|
||||
this.defaultValues[key] = defaultConfiguration[key];
|
||||
const property = this.configurationProperties[key];
|
||||
if (property) {
|
||||
this.updatePropertyDefaultValue(key, property);
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
|
||||
suite('ConfigurationRegistry', () => {
|
||||
|
||||
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
|
||||
|
||||
test('configuration override', async () => {
|
||||
configurationRegistry.registerConfiguration({
|
||||
'id': '_test_default',
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'config': {
|
||||
'type': 'object',
|
||||
}
|
||||
}
|
||||
});
|
||||
configurationRegistry.registerDefaultConfigurations([{ 'config': { a: 1, b: 2 } }]);
|
||||
configurationRegistry.registerDefaultConfigurations([{ '[lang]': { a: 2, c: 3 } }]);
|
||||
|
||||
assert.deepEqual(configurationRegistry.getConfigurationProperties()['config'].default, { a: 1, b: 2 });
|
||||
assert.deepEqual(configurationRegistry.getConfigurationProperties()['[lang]'].default, { a: 2, c: 3 });
|
||||
});
|
||||
|
||||
test('configuration override defaults - merges defaults', async () => {
|
||||
configurationRegistry.registerDefaultConfigurations([{ '[lang]': { a: 1, b: 2 } }]);
|
||||
configurationRegistry.registerDefaultConfigurations([{ '[lang]': { a: 2, c: 3 } }]);
|
||||
|
||||
assert.deepEqual(configurationRegistry.getConfigurationProperties()['[lang]'].default, { a: 2, b: 2, c: 3 });
|
||||
});
|
||||
|
||||
test('configuration defaults - overrides defaults', async () => {
|
||||
configurationRegistry.registerConfiguration({
|
||||
'id': '_test_default',
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'config': {
|
||||
'type': 'object',
|
||||
}
|
||||
}
|
||||
});
|
||||
configurationRegistry.registerDefaultConfigurations([{ 'config': { a: 1, b: 2 } }]);
|
||||
configurationRegistry.registerDefaultConfigurations([{ 'config': { a: 2, c: 3 } }]);
|
||||
|
||||
assert.deepEqual(configurationRegistry.getConfigurationProperties()['config'].default, { a: 2, c: 3 });
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue