提交 e8ddfed2 编写于 作者: J Johannes Rieken

getConfiguration should not crash when section denotes a value, #1396

上级 2de9e462
......@@ -15,7 +15,7 @@ suite('workspace-namespace', () => {
teardown(cleanUp);
test('default configuration', () => {
test('configuration, defaults', () => {
const config = workspace.getConfiguration('farboo');
assert.ok(config.has('config0'));
......@@ -26,6 +26,11 @@ suite('workspace-namespace', () => {
assert.equal(config.get('nested.config2'), 'Das Pferd frisst kein Reis.');
});
test('configuration, getConfig/value', () => {
const value = workspace.getConfiguration('farboo.config0');
assert.equal(Object.keys(value).length, 2);
});
test('textDocuments', () => {
assert.ok(Array.isArray(workspace.textDocuments));
assert.throws(() => workspace.textDocuments = null);
......
......@@ -41,9 +41,14 @@ export class ExtHostConfiguration {
? ExtHostConfiguration._lookUp(section, this._config)
: this._config;
let result: any;
if (typeof config !== 'object') {
// this catches missing config and accessing values
result = {};
} else {
result = clone(config);
}
let result = config ? clone(config) : {};
// result = Object.freeze(result);
result.has = function(key: string): boolean {
return typeof ExtHostConfiguration._lookUp(key, config) !== 'undefined';
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册