@@ -15,7 +15,7 @@ import { ConfigurationModel, ConfigurationChangeEvent, mergeChanges } from 'vs/p
15
15
import { IConfigurationChangeEvent , ConfigurationTarget , IConfigurationOverrides , isConfigurationOverrides , IConfigurationData , IConfigurationValue , IConfigurationChange , ConfigurationTargetToString , IConfigurationUpdateOverrides , isConfigurationUpdateOverrides , IConfigurationService , IConfigurationUpdateOptions } from 'vs/platform/configuration/common/configuration' ;
16
16
import { IPolicyConfiguration , NullPolicyConfiguration , PolicyConfiguration } from 'vs/platform/configuration/common/configurations' ;
17
17
import { Configuration } from 'vs/workbench/services/configuration/common/configurationModels' ;
18
- import { FOLDER_CONFIG_FOLDER_NAME , defaultSettingsSchemaId , userSettingsSchemaId , workspaceSettingsSchemaId , folderSettingsSchemaId , IConfigurationCache , machineSettingsSchemaId , LOCAL_MACHINE_SCOPES , IWorkbenchConfigurationService , RestrictedSettings , PROFILE_SCOPES , LOCAL_MACHINE_PROFILE_SCOPES , profileSettingsSchemaId } from 'vs/workbench/services/configuration/common/configuration' ;
18
+ import { FOLDER_CONFIG_FOLDER_NAME , defaultSettingsSchemaId , userSettingsSchemaId , workspaceSettingsSchemaId , folderSettingsSchemaId , IConfigurationCache , machineSettingsSchemaId , LOCAL_MACHINE_SCOPES , IWorkbenchConfigurationService , RestrictedSettings , PROFILE_SCOPES , LOCAL_MACHINE_PROFILE_SCOPES , profileSettingsSchemaId , APPLY_ALL_PROFILES_SETTING } from 'vs/workbench/services/configuration/common/configuration' ;
19
19
import { Registry } from 'vs/platform/registry/common/platform' ;
20
20
import { IConfigurationRegistry , Extensions , allSettings , windowSettings , resourceSettings , applicationSettings , machineSettings , machineOverridableSettings , ConfigurationScope , IConfigurationPropertySchema , keyFromOverrideIdentifiers , OVERRIDE_PROPERTY_PATTERN , resourceLanguageSettingsSchemaId , configurationDefaultsSchemaId } from 'vs/platform/configuration/common/configurationRegistry' ;
21
21
import { IStoredWorkspaceFolder , isStoredWorkspaceFolder , IWorkspaceFolderCreationData , getStoredWorkspaceFolder , toWorkspaceFolders } from 'vs/platform/workspaces/common/workspaces' ;
@@ -44,6 +44,7 @@ import { IPolicyService, NullPolicyService } from 'vs/platform/policy/common/pol
44
44
import { IUserDataProfile , IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile' ;
45
45
import { IJSONEditingService } from 'vs/workbench/services/configuration/common/jsonEditing' ;
46
46
import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService' ;
47
+ import { workbenchConfigurationNodeBase } from 'vs/workbench/common/configuration' ;
47
48
48
49
function getLocalUserConfigurationScopes ( userDataProfile : IUserDataProfile , hasRemote : boolean ) : ConfigurationScope [ ] | undefined {
49
50
return userDataProfile . isDefault
@@ -489,7 +490,11 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
489
490
}
490
491
491
492
isSettingAppliedForAllProfiles ( key : string ) : boolean {
492
- return this . configurationRegistry . getConfigurationProperties ( ) [ key ] ?. scope === ConfigurationScope . APPLICATION ;
493
+ if ( this . configurationRegistry . getConfigurationProperties ( ) [ key ] ?. scope === ConfigurationScope . APPLICATION ) {
494
+ return true ;
495
+ }
496
+ const allProfilesSettings = this . getValue < string [ ] > ( APPLY_ALL_PROFILES_SETTING ) ?? [ ] ;
497
+ return Array . isArray ( allProfilesSettings ) && allProfilesSettings . includes ( key ) ;
493
498
}
494
499
495
500
private async createWorkspace ( arg : IAnyWorkspaceIdentifier ) : Promise < Workspace > {
@@ -601,6 +606,10 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
601
606
const initUserConfiguration = async ( ) => {
602
607
mark ( 'code/willInitUserConfiguration' ) ;
603
608
const result = await Promise . all ( [ this . localUserConfiguration . initialize ( ) , this . remoteUserConfiguration ? this . remoteUserConfiguration . initialize ( ) : Promise . resolve ( new ConfigurationModel ( ) ) ] ) ;
609
+ if ( this . applicationConfiguration ) {
610
+ const applicationConfigurationModel = await initApplicationConfigurationPromise ;
611
+ result [ 0 ] = this . localUserConfiguration . reparse ( { exclude : applicationConfigurationModel . getValue ( APPLY_ALL_PROFILES_SETTING ) } ) ;
612
+ }
604
613
mark ( 'code/didInitUserConfiguration' ) ;
605
614
return result ;
606
615
} ;
@@ -714,8 +723,12 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
714
723
promises . push ( this . reloadApplicationConfiguration ( true ) ) ;
715
724
}
716
725
}
717
- const [ localUser , application ] = await Promise . all ( promises ) ;
718
- await this . loadConfiguration ( application ?? this . _configuration . applicationConfiguration , localUser , this . _configuration . remoteUserConfiguration , true ) ;
726
+ let [ localUser , application ] = await Promise . all ( promises ) ;
727
+ application = application ?? this . _configuration . applicationConfiguration ;
728
+ if ( this . applicationConfiguration ) {
729
+ localUser = this . localUserConfiguration . reparse ( { exclude : application . getValue ( APPLY_ALL_PROFILES_SETTING ) } ) ;
730
+ }
731
+ await this . loadConfiguration ( application , localUser , this . _configuration . remoteUserConfiguration , true ) ;
719
732
} ) ( ) ) ;
720
733
}
721
734
@@ -758,15 +771,35 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
758
771
759
772
private onApplicationConfigurationChanged ( applicationConfiguration : ConfigurationModel ) : void {
760
773
const previous = { data : this . _configuration . toData ( ) , workspace : this . workspace } ;
774
+ const previousAllProfilesSettings = this . _configuration . applicationConfiguration . getValue < string [ ] > ( APPLY_ALL_PROFILES_SETTING ) ?? [ ] ;
761
775
const change = this . _configuration . compareAndUpdateApplicationConfiguration ( applicationConfiguration ) ;
776
+ const currentAllProfilesSettings = this . getValue < string [ ] > ( APPLY_ALL_PROFILES_SETTING ) ?? [ ] ;
762
777
const configurationProperties = this . configurationRegistry . getConfigurationProperties ( ) ;
763
778
const changedKeys : string [ ] = [ ] ;
764
779
for ( const changedKey of change . keys ) {
765
780
if ( configurationProperties [ changedKey ] ?. scope === ConfigurationScope . APPLICATION ) {
766
781
changedKeys . push ( changedKey ) ;
782
+ if ( changedKey === APPLY_ALL_PROFILES_SETTING ) {
783
+ for ( const previousAllProfileSetting of previousAllProfilesSettings ) {
784
+ if ( ! currentAllProfilesSettings . includes ( previousAllProfileSetting ) ) {
785
+ changedKeys . push ( previousAllProfileSetting ) ;
786
+ }
787
+ }
788
+ for ( const currentAllProfileSetting of currentAllProfilesSettings ) {
789
+ if ( ! previousAllProfilesSettings . includes ( currentAllProfileSetting ) ) {
790
+ changedKeys . push ( currentAllProfileSetting ) ;
791
+ }
792
+ }
793
+ }
794
+ }
795
+ else if ( currentAllProfilesSettings . includes ( changedKey ) ) {
796
+ changedKeys . push ( changedKey ) ;
767
797
}
768
798
}
769
799
change . keys = changedKeys ;
800
+ if ( change . keys . includes ( APPLY_ALL_PROFILES_SETTING ) ) {
801
+ this . _configuration . updateLocalUserConfiguration ( this . localUserConfiguration . reparse ( { exclude : currentAllProfilesSettings } ) ) ;
802
+ }
770
803
this . triggerConfigurationChange ( change , previous , ConfigurationTarget . USER ) ;
771
804
}
772
805
@@ -1318,3 +1351,18 @@ const workbenchContributionsRegistry = Registry.as<IWorkbenchContributionsRegist
1318
1351
workbenchContributionsRegistry . registerWorkbenchContribution ( RegisterConfigurationSchemasContribution , LifecyclePhase . Restored ) ;
1319
1352
workbenchContributionsRegistry . registerWorkbenchContribution ( ResetConfigurationDefaultsOverridesCache , LifecyclePhase . Eventually ) ;
1320
1353
workbenchContributionsRegistry . registerWorkbenchContribution ( UpdateExperimentalSettingsDefaults , LifecyclePhase . Restored ) ;
1354
+
1355
+ const configurationRegistry = Registry . as < IConfigurationRegistry > ( Extensions . Configuration ) ;
1356
+ configurationRegistry . registerConfiguration ( {
1357
+ ...workbenchConfigurationNodeBase ,
1358
+ properties : {
1359
+ [ APPLY_ALL_PROFILES_SETTING ] : {
1360
+ 'type' : 'array' ,
1361
+ description : localize ( 'setting description' , "Configure settings to be applied for all profiles." ) ,
1362
+ 'default' : [ ] ,
1363
+ 'scope' : ConfigurationScope . APPLICATION ,
1364
+ additionalProperties : true ,
1365
+ uniqueItems : true ,
1366
+ }
1367
+ }
1368
+ } ) ;
0 commit comments