Skip to content

Commit 2442049

Browse files
committed
1 parent 4cc18ec commit 2442049

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

src/vs/workbench/api/node/extHostConfiguration.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape {
100100
let clonedConfig = void 0;
101101
const cloneOnWriteProxy = (target: any, accessor: string): any => {
102102
let clonedTarget = void 0;
103+
const cloneTarget = () => {
104+
clonedConfig = clonedConfig ? clonedConfig : deepClone(config);
105+
clonedTarget = clonedTarget ? clonedTarget : lookUp(clonedConfig, accessor);
106+
};
103107
return isObject(target) ?
104108
new Proxy(target, {
105109
get: (target: any, property: string) => {
@@ -114,10 +118,19 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape {
114118
return result;
115119
},
116120
set: (target: any, property: string, value: any) => {
117-
clonedConfig = clonedConfig ? clonedConfig : deepClone(config);
118-
clonedTarget = clonedTarget ? clonedTarget : lookUp(clonedConfig, accessor);
121+
cloneTarget();
119122
clonedTarget[property] = value;
120123
return true;
124+
},
125+
deleteProperty: (target: any, property: string) => {
126+
cloneTarget();
127+
delete clonedTarget[property];
128+
return true;
129+
},
130+
defineProperty: (target: any, property: string, descriptor: any) => {
131+
cloneTarget();
132+
Object.defineProperty(clonedTarget, property, descriptor);
133+
return true;
121134
}
122135
}) : target;
123136
};

src/vs/workbench/test/electron-browser/api/extHostConfiguration.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ suite('ExtHostConfiguration', function () {
102102
'config2': 'Das Pferd frisst kein Reis.'
103103
},
104104
'config4': ''
105+
},
106+
'workbench': {
107+
'colorCustomizations': {
108+
'statusBar.foreground': 'somevalue'
109+
}
105110
}
106111
});
107112

@@ -131,6 +136,14 @@ suite('ExtHostConfiguration', function () {
131136
actual = testObject.inspect('farboo');
132137
actual['value'] = 'effectiveValue';
133138
assert.equal('effectiveValue', actual['value']);
139+
140+
testObject = all.getConfiguration('workbench');
141+
actual = testObject.get('colorCustomizations');
142+
delete actual['statusBar.foreground'];
143+
assert.equal(actual['statusBar.foreground'], undefined);
144+
testObject = all.getConfiguration('workbench');
145+
actual = testObject.get('colorCustomizations');
146+
assert.equal(actual['statusBar.foreground'], 'somevalue');
134147
});
135148

136149
test('cannot modify returned configuration', function () {
@@ -158,7 +171,6 @@ suite('ExtHostConfiguration', function () {
158171
testObject['farboo']['config0'] = false;
159172
assert.fail('This should be readonly');
160173
} catch (e) {
161-
console.log(e);
162174
}
163175

164176
try {

0 commit comments

Comments
 (0)