mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
#51935 fix overrides keys in configuration model while merging
This commit is contained in:
parent
4dde912b9e
commit
de269bbbf2
|
@ -89,6 +89,8 @@ export class ConfigurationModel implements IConfigurationModel {
|
|||
const [override] = overrides.filter(o => arrays.equals(o.identifiers, otherOverride.identifiers));
|
||||
if (override) {
|
||||
this.mergeContents(override.contents, otherOverride.contents);
|
||||
override.keys.push(...otherOverride.keys);
|
||||
override.keys = arrays.distinct(override.keys);
|
||||
} else {
|
||||
overrides.push(objects.deepClone(otherOverride));
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ suite('ConfigurationModel', () => {
|
|||
let result = base.merge(add);
|
||||
|
||||
assert.deepStrictEqual(result.contents, { 'a': { 'b': 2 } });
|
||||
assert.deepStrictEqual(result.overrides, [{ identifiers: ['c'], contents: { 'a': 2, 'b': 2 }, keys: ['a'] }]);
|
||||
assert.deepStrictEqual(result.overrides, [{ identifiers: ['c'], contents: { 'a': 2, 'b': 2 }, keys: ['a', 'b'] }]);
|
||||
assert.deepStrictEqual(result.override('c').contents, { 'a': 2, 'b': 2 });
|
||||
assert.deepStrictEqual(result.keys, ['a.b']);
|
||||
});
|
||||
|
@ -260,6 +260,21 @@ suite('ConfigurationModel', () => {
|
|||
|
||||
assert.deepStrictEqual(testObject.getKeysForOverrideIdentifier('x'), ['a', 'b']);
|
||||
});
|
||||
|
||||
test('Test merge when configuration models have multiple identifiers', () => {
|
||||
const testObject = new ConfigurationModel({ 'a': 1, 'c': 1 }, ['a', 'c'], [{ identifiers: ['y'], contents: { 'c': 1 }, keys: ['c'] }, { identifiers: ['x', 'y'], contents: { 'a': 2 }, keys: ['a'] }]);
|
||||
const target = new ConfigurationModel({ 'a': 2, 'b': 1 }, ['a', 'b'], [{ identifiers: ['x'], contents: { 'a': 3, 'b': 2 }, keys: ['a', 'b'] }, { identifiers: ['x', 'y'], contents: { 'b': 3 }, keys: ['b'] }]);
|
||||
|
||||
const actual = testObject.merge(target);
|
||||
|
||||
assert.deepStrictEqual(actual.contents, { 'a': 2, 'c': 1, 'b': 1 });
|
||||
assert.deepStrictEqual(actual.keys, ['a', 'c', 'b']);
|
||||
assert.deepStrictEqual(actual.overrides, [
|
||||
{ identifiers: ['y'], contents: { 'c': 1 }, keys: ['c'] },
|
||||
{ identifiers: ['x', 'y'], contents: { 'a': 2, 'b': 3 }, keys: ['a', 'b'] },
|
||||
{ identifiers: ['x'], contents: { 'a': 3, 'b': 2 }, keys: ['a', 'b'] },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
suite('CustomConfigurationModel', () => {
|
||||
|
|
Loading…
Reference in a new issue