diff --git a/src/vs/workbench/services/configuration/node/configuration.ts b/src/vs/workbench/services/configuration/node/configuration.ts index 79e24da0d55ae0dbd08c8f7b9e6a5d2708b70966..983bf2b902f16bffefc3f0e8404345fe15703715 100644 --- a/src/vs/workbench/services/configuration/node/configuration.ts +++ b/src/vs/workbench/services/configuration/node/configuration.ts @@ -24,6 +24,7 @@ import { JSONEditingService } from 'vs/workbench/services/configuration/node/jso import { WorkbenchState } from 'vs/platform/workspace/common/workspace'; import { ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry'; import { relative } from 'path'; +import { equals } from 'vs/base/common/objects'; // node.hs helper functions @@ -189,10 +190,9 @@ export class FolderConfiguration extends Disposable { } reprocess(): ConfigurationModel { - const oldKeys = this.getUnsupportedKeys(); + const oldContents = this._folderSettingsModelParser.folderSettingsModel.contents; this._folderSettingsModelParser.reprocess(); - const newKeys = this.getUnsupportedKeys(); - if (this.hasKeysChanged(oldKeys, newKeys)) { + if (!equals(oldContents, this._folderSettingsModelParser.folderSettingsModel.contents)) { this.consolidate(); } return this._cache; @@ -202,18 +202,6 @@ export class FolderConfiguration extends Disposable { return this._folderSettingsModelParser.folderSettingsModel.unsupportedKeys; } - private hasKeysChanged(oldKeys: string[], newKeys: string[]): boolean { - if (oldKeys.length !== newKeys.length) { - return true; - } - for (const key of oldKeys) { - if (newKeys.indexOf(key) === -1) { - return true; - } - } - return false; - } - private consolidate(): void { this._cache = this._folderSettingsModelParser.folderSettingsModel.merge(...this._standAloneConfigurations); } diff --git a/src/vs/workbench/services/configuration/test/node/configurationService.test.ts b/src/vs/workbench/services/configuration/test/node/configurationService.test.ts index eaa5fa0c3371d165af5345eda5c01017ac32de4c..d41ac767a6901cc0da0f1c90cbd1b4b7503a7511 100644 --- a/src/vs/workbench/services/configuration/test/node/configurationService.test.ts +++ b/src/vs/workbench/services/configuration/test/node/configurationService.test.ts @@ -968,6 +968,26 @@ suite('WorkspaceConfigurationService - Multiroot', () => { }); }); + test('resource setting in folder is read after it is registered later', () => { + fs.writeFileSync(workspaceContextService.getWorkspace().folders[0].toResource('.vscode/settings.json').fsPath, '{ "configurationService.workspace.testNewResourceSetting2": "workspaceFolderValue" }'); + return jsonEditingServce.write(workspaceContextService.getWorkspace().configuration, { key: 'settings', value: { 'configurationService.workspace.testNewResourceSetting2': 'workspaceValue' } }, true) + .then(() => testObject.reloadConfiguration()) + .then(() => { + configurationRegistry.registerConfiguration({ + 'id': '_test', + 'type': 'object', + 'properties': { + 'configurationService.workspace.testNewResourceSetting2': { + 'type': 'string', + 'default': 'isSet', + scope: ConfigurationScope.RESOURCE + } + } + }); + assert.equal(testObject.getValue('configurationService.workspace.testNewResourceSetting2', { resource: workspaceContextService.getWorkspace().folders[0].uri }), 'workspaceFolderValue'); + }); + }); + test('inspect', () => { let actual = testObject.inspect('something.missing'); assert.equal(actual.default, void 0);