@@ -14,6 +14,8 @@ import { OVERRIDE_PROPERTY_PATTERN } from 'vs/platform/configuration/common/conf
1414import { IOverrides , overrideIdentifierFromKey , addToValueTree , toValuesTree , IConfigurationModel , getConfigurationValue , IConfigurationOverrides , IConfigurationData , getDefaultValues , getConfigurationKeys , IConfigurationChangeEvent , ConfigurationTarget , removeFromValueTree , toOverrides } from 'vs/platform/configuration/common/configuration' ;
1515import { Workspace } from 'vs/platform/workspace/common/workspace' ;
1616
17+ declare const Proxy : any ; // TODO@TypeScript
18+
1719export class ConfigurationModel implements IConfigurationModel {
1820
1921 private isFrozen : boolean = false ;
@@ -291,7 +293,8 @@ export class Configuration {
291293
292294 getValue ( section : string , overrides : IConfigurationOverrides , workspace : Workspace ) : any {
293295 const consolidateConfigurationModel = this . getConsolidateConfigurationModel ( overrides , workspace ) ;
294- return consolidateConfigurationModel . getValue ( section ) ;
296+ const result = consolidateConfigurationModel . getValue ( section ) ;
297+ return this . toReadonlyValue ( result ) ;
295298 }
296299
297300 updateValue ( key : string , value : any , overrides : IConfigurationOverrides = { } ) : void {
@@ -334,7 +337,7 @@ export class Configuration {
334337 workspace : workspace ? overrides . overrideIdentifier ? this . _workspaceConfiguration . freeze ( ) . override ( overrides . overrideIdentifier ) . getValue ( key ) : this . _workspaceConfiguration . freeze ( ) . getValue ( key ) : void 0 , //Check on workspace exists or not because _workspaceConfiguration is never null
335338 workspaceFolder : folderConfigurationModel ? overrides . overrideIdentifier ? folderConfigurationModel . freeze ( ) . override ( overrides . overrideIdentifier ) . getValue ( key ) : folderConfigurationModel . freeze ( ) . getValue ( key ) : void 0 ,
336339 memory : overrides . overrideIdentifier ? memoryConfigurationModel . freeze ( ) . override ( overrides . overrideIdentifier ) . getValue ( key ) : memoryConfigurationModel . freeze ( ) . getValue ( key ) ,
337- value : consolidateConfigurationModel . getValue ( key )
340+ value : this . toReadonlyValue ( consolidateConfigurationModel . getValue ( key ) )
338341 } ;
339342 }
340343
@@ -421,7 +424,7 @@ export class Configuration {
421424
422425 private getWorkspaceConsolidatedConfiguration ( ) : ConfigurationModel {
423426 if ( ! this . _workspaceConsolidatedConfiguration ) {
424- this . _workspaceConsolidatedConfiguration = this . _defaultConfiguration . merge ( this . _userConfiguration ) . merge ( this . _workspaceConfiguration ) . merge ( this . _memoryConfiguration ) . freeze ( ) ;
427+ this . _workspaceConsolidatedConfiguration = this . _defaultConfiguration . merge ( this . _userConfiguration , this . _workspaceConfiguration , this . _memoryConfiguration ) ;
425428 }
426429 return this . _workspaceConsolidatedConfiguration ;
427430 }
@@ -432,7 +435,7 @@ export class Configuration {
432435 const workspaceConsolidateConfiguration = this . getWorkspaceConsolidatedConfiguration ( ) ;
433436 const folderConfiguration = this . _folderConfigurations . get ( folder ) ;
434437 if ( folderConfiguration ) {
435- folderConsolidatedConfiguration = workspaceConsolidateConfiguration . merge ( folderConfiguration ) . freeze ( ) ;
438+ folderConsolidatedConfiguration = workspaceConsolidateConfiguration . merge ( folderConfiguration ) ;
436439 this . _foldersConsolidatedConfigurations . set ( folder , folderConsolidatedConfiguration ) ;
437440 } else {
438441 folderConsolidatedConfiguration = workspaceConsolidateConfiguration ;
@@ -451,6 +454,22 @@ export class Configuration {
451454 return null ;
452455 }
453456
457+ private toReadonlyValue ( result : any ) : any {
458+ const readonlyProxy = ( target ) => {
459+ return types . isObject ( target ) ?
460+ new Proxy ( target , {
461+ get : ( target : any , property : string ) => readonlyProxy ( target [ property ] ) ,
462+ set : ( target : any , property : string , value : any ) => { throw new Error ( `TypeError: Cannot assign to read only property '${ property } ' of object` ) ; } ,
463+ deleteProperty : ( target : any , property : string ) => { throw new Error ( `TypeError: Cannot delete read only property '${ property } ' of object` ) ; } ,
464+ defineProperty : ( target : any , property : string ) => { throw new Error ( `TypeError: Cannot define property '${ property } ' for a readonly object` ) ; } ,
465+ setPrototypeOf : ( target : any ) => { throw new Error ( `TypeError: Cannot set prototype for a readonly object` ) ; } ,
466+ isExtensible : ( ) => false ,
467+ preventExtensions : ( ) => true
468+ } ) : target ;
469+ } ;
470+ return readonlyProxy ( result ) ;
471+ }
472+
454473 toData ( ) : IConfigurationData {
455474 return {
456475 defaults : {
0 commit comments