diff --git a/src/vs/workbench/api/node/extHostConfiguration.ts b/src/vs/workbench/api/node/extHostConfiguration.ts index ec5f0f695f5..97b64ea997f 100644 --- a/src/vs/workbench/api/node/extHostConfiguration.ts +++ b/src/vs/workbench/api/node/extHostConfiguration.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { mixin } from 'vs/base/common/objects'; +import { mixin, clone } from 'vs/base/common/objects'; import URI from 'vs/base/common/uri'; import Event, { Emitter } from 'vs/base/common/event'; import * as vscode from 'vscode'; @@ -61,9 +61,9 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape { } getConfiguration(section?: string, resource?: URI, extensionId?: string): vscode.WorkspaceConfiguration { - const config = section + const config = clone(section ? lookUp(this._configuration.getValue(null, { resource }, this._extHostWorkspace.workspace), section) - : this._configuration.getValue(null, { resource }, this._extHostWorkspace.workspace); + : this._configuration.getValue(null, { resource }, this._extHostWorkspace.workspace)); if (section) { this._validateConfigurationAccess(section, resource, extensionId); @@ -107,7 +107,7 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape { }, inspect: (key: string): ConfigurationInspect => { key = section ? `${section}.${key}` : key; - const config = this._configuration.lookup(key, { resource }, this._extHostWorkspace.workspace); + const config = clone(this._configuration.lookup(key, { resource }, this._extHostWorkspace.workspace)); if (config) { return { key, diff --git a/src/vs/workbench/test/electron-browser/api/extHostConfiguration.test.ts b/src/vs/workbench/test/electron-browser/api/extHostConfiguration.test.ts index 82706da5942..0601b4b7f74 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostConfiguration.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostConfiguration.test.ts @@ -104,16 +104,32 @@ suite('ExtHostConfiguration', function () { } }); - const testObject = all.getConfiguration(); + let testObject = all.getConfiguration(); let actual = testObject.get('farboo'); actual['farboo1'] = 'newValue'; - assert.equal('newValue', actual['farboo1']); + testObject = all.getConfiguration(); + testObject['farboo']['farboo1'] = 'newValue'; + assert.equal('newValue', testObject['farboo']['farboo1']); + + testObject = all.getConfiguration(); + testObject['farboo']['farboo1'] = 'newValue'; + assert.equal('newValue', testObject.get('farboo')['farboo1']); + + testObject = all.getConfiguration(); actual = testObject.inspect('farboo'); actual['value'] = 'effectiveValue'; - assert.equal('effectiveValue', actual['value']); + + testObject = all.getConfiguration(); + actual = testObject.get('farboo'); + assert.equal(undefined, actual['farboo1']); + + testObject = all.getConfiguration(); + testObject['farboo']['farboo1'] = 'newValue'; + testObject = all.getConfiguration(); + assert.equal(undefined, testObject['farboo']['farboo1']); }); test('inspect in no workspace context', function () {