@@ -36,6 +36,10 @@ export class ConfigurationModel implements IConfigurationModel {
3636 return this . checkAndFreeze ( this . _keys ) ;
3737 }
3838
39+ isEmpty ( ) : boolean {
40+ return this . _keys . length === 0 || Object . keys ( this . _contents ) . length === 0 || this . _overrides . length === 0 ;
41+ }
42+
3943 getValue < V > ( section : string | undefined ) : V {
4044 return section ? getConfigurationValue < any > ( this . contents , section ) : this . contents ;
4145 }
@@ -283,7 +287,8 @@ export class Configuration {
283287
284288 constructor (
285289 private _defaultConfiguration : ConfigurationModel ,
286- private _userConfiguration : ConfigurationModel ,
290+ private _localUserConfiguration : ConfigurationModel ,
291+ private _remoteUserConfiguration : ConfigurationModel = new ConfigurationModel ( ) ,
287292 private _workspaceConfiguration : ConfigurationModel = new ConfigurationModel ( ) ,
288293 private _folderConfigurations : ResourceMap < ConfigurationModel > = new ResourceMap < ConfigurationModel > ( ) ,
289294 private _memoryConfiguration : ConfigurationModel = new ConfigurationModel ( ) ,
@@ -322,6 +327,8 @@ export class Configuration {
322327 inspect < C > ( key : string , overrides : IConfigurationOverrides , workspace : Workspace | undefined ) : {
323328 default : C ,
324329 user : C ,
330+ userLocal ?: C ,
331+ userRemote ?: C ,
325332 workspace ?: C ,
326333 workspaceFolder ?: C
327334 memory ?: C
@@ -332,7 +339,9 @@ export class Configuration {
332339 const memoryConfigurationModel = overrides . resource ? this . _memoryConfigurationByResource . get ( overrides . resource ) || this . _memoryConfiguration : this . _memoryConfiguration ;
333340 return {
334341 default : overrides . overrideIdentifier ? this . _defaultConfiguration . freeze ( ) . override ( overrides . overrideIdentifier ) . getValue ( key ) : this . _defaultConfiguration . freeze ( ) . getValue ( key ) ,
335- user : overrides . overrideIdentifier ? this . _userConfiguration . freeze ( ) . override ( overrides . overrideIdentifier ) . getValue ( key ) : this . _userConfiguration . freeze ( ) . getValue ( key ) ,
342+ user : overrides . overrideIdentifier ? this . userConfiguration . freeze ( ) . override ( overrides . overrideIdentifier ) . getValue ( key ) : this . userConfiguration . freeze ( ) . getValue ( key ) ,
343+ userLocal : overrides . overrideIdentifier ? this . localUserConfiguration . freeze ( ) . override ( overrides . overrideIdentifier ) . getValue ( key ) : this . localUserConfiguration . freeze ( ) . getValue ( key ) ,
344+ userRemote : overrides . overrideIdentifier ? this . remoteUserConfiguration . freeze ( ) . override ( overrides . overrideIdentifier ) . getValue ( key ) : this . remoteUserConfiguration . freeze ( ) . getValue ( key ) ,
336345 workspace : workspace ? overrides . overrideIdentifier ? this . _workspaceConfiguration . freeze ( ) . override ( overrides . overrideIdentifier ) . getValue ( key ) : this . _workspaceConfiguration . freeze ( ) . getValue ( key ) : undefined , //Check on workspace exists or not because _workspaceConfiguration is never null
337346 workspaceFolder : folderConfigurationModel ? overrides . overrideIdentifier ? folderConfigurationModel . freeze ( ) . override ( overrides . overrideIdentifier ) . getValue ( key ) : folderConfigurationModel . freeze ( ) . getValue ( key ) : undefined ,
338347 memory : overrides . overrideIdentifier ? memoryConfigurationModel . override ( overrides . overrideIdentifier ) . getValue ( key ) : memoryConfigurationModel . getValue ( key ) ,
@@ -349,7 +358,7 @@ export class Configuration {
349358 const folderConfigurationModel = this . getFolderConfigurationModelForResource ( undefined , workspace ) ;
350359 return {
351360 default : this . _defaultConfiguration . freeze ( ) . keys ,
352- user : this . _userConfiguration . freeze ( ) . keys ,
361+ user : this . userConfiguration . freeze ( ) . keys ,
353362 workspace : this . _workspaceConfiguration . freeze ( ) . keys ,
354363 workspaceFolder : folderConfigurationModel ? folderConfigurationModel . freeze ( ) . keys : [ ]
355364 } ;
@@ -361,8 +370,16 @@ export class Configuration {
361370 this . _foldersConsolidatedConfigurations . clear ( ) ;
362371 }
363372
364- updateUserConfiguration ( userConfiguration : ConfigurationModel ) : void {
365- this . _userConfiguration = userConfiguration ;
373+ updateLocalUserConfiguration ( localUserConfiguration : ConfigurationModel ) : void {
374+ this . _localUserConfiguration = localUserConfiguration ;
375+ this . _userConfiguration = null ;
376+ this . _workspaceConsolidatedConfiguration = null ;
377+ this . _foldersConsolidatedConfigurations . clear ( ) ;
378+ }
379+
380+ updateRemoteUserConfiguration ( remoteUserConfiguration : ConfigurationModel ) : void {
381+ this . _remoteUserConfiguration = remoteUserConfiguration ;
382+ this . _userConfiguration = null ;
366383 this . _workspaceConsolidatedConfiguration = null ;
367384 this . _foldersConsolidatedConfigurations . clear ( ) ;
368385 }
@@ -379,23 +396,38 @@ export class Configuration {
379396 }
380397
381398 deleteFolderConfiguration ( resource : URI ) : void {
382- this . folders . delete ( resource ) ;
399+ this . folderConfigurations . delete ( resource ) ;
383400 this . _foldersConsolidatedConfigurations . delete ( resource ) ;
384401 }
385402
386403 get defaults ( ) : ConfigurationModel {
387404 return this . _defaultConfiguration ;
388405 }
389406
390- get user ( ) : ConfigurationModel {
407+ private _userConfiguration : ConfigurationModel | null ;
408+ get userConfiguration ( ) : ConfigurationModel {
409+ if ( ! this . _userConfiguration ) {
410+ this . _userConfiguration = this . _remoteUserConfiguration . isEmpty ( ) ? this . _localUserConfiguration : this . _localUserConfiguration . merge ( this . _remoteUserConfiguration ) ;
411+ if ( this . _freeze ) {
412+ this . _userConfiguration . freeze ( ) ;
413+ }
414+ }
391415 return this . _userConfiguration ;
392416 }
393417
394- get workspace ( ) : ConfigurationModel {
418+ get localUserConfiguration ( ) : ConfigurationModel {
419+ return this . _localUserConfiguration ;
420+ }
421+
422+ get remoteUserConfiguration ( ) : ConfigurationModel {
423+ return this . _remoteUserConfiguration ;
424+ }
425+
426+ get workspaceConfiguration ( ) : ConfigurationModel {
395427 return this . _workspaceConfiguration ;
396428 }
397429
398- protected get folders ( ) : ResourceMap < ConfigurationModel > {
430+ protected get folderConfigurations ( ) : ResourceMap < ConfigurationModel > {
399431 return this . _folderConfigurations ;
400432 }
401433
@@ -423,7 +455,7 @@ export class Configuration {
423455
424456 private getWorkspaceConsolidatedConfiguration ( ) : ConfigurationModel {
425457 if ( ! this . _workspaceConsolidatedConfiguration ) {
426- this . _workspaceConsolidatedConfiguration = this . _defaultConfiguration . merge ( this . _userConfiguration , this . _workspaceConfiguration , this . _memoryConfiguration ) ;
458+ this . _workspaceConsolidatedConfiguration = this . _defaultConfiguration . merge ( this . userConfiguration , this . _workspaceConfiguration , this . _memoryConfiguration ) ;
427459 if ( this . _freeze ) {
428460 this . _workspaceConfiguration = this . _workspaceConfiguration . freeze ( ) ;
429461 }
@@ -467,9 +499,9 @@ export class Configuration {
467499 keys : this . _defaultConfiguration . keys
468500 } ,
469501 user : {
470- contents : this . _userConfiguration . contents ,
471- overrides : this . _userConfiguration . overrides ,
472- keys : this . _userConfiguration . keys
502+ contents : this . userConfiguration . contents ,
503+ overrides : this . userConfiguration . overrides ,
504+ keys : this . userConfiguration . keys
473505 } ,
474506 workspace : {
475507 contents : this . _workspaceConfiguration . contents ,
@@ -497,8 +529,8 @@ export class Configuration {
497529 } ;
498530 addKeys ( keys . user ) ;
499531 addKeys ( keys . workspace ) ;
500- for ( const resource of this . folders . keys ( ) ) {
501- addKeys ( this . folders . get ( resource ) ! . keys ) ;
532+ for ( const resource of this . folderConfigurations . keys ( ) ) {
533+ addKeys ( this . folderConfigurations . get ( resource ) ! . keys ) ;
502534 }
503535 return all ;
504536 }
0 commit comments