@@ -15,7 +15,7 @@ import { ConfigurationModel, ConfigurationChangeEvent, mergeChanges } from 'vs/p
1515import { IConfigurationChangeEvent , ConfigurationTarget , IConfigurationOverrides , isConfigurationOverrides , IConfigurationData , IConfigurationValue , IConfigurationChange , ConfigurationTargetToString , IConfigurationUpdateOverrides , isConfigurationUpdateOverrides , IConfigurationService , IConfigurationUpdateOptions } from 'vs/platform/configuration/common/configuration' ;
1616import { IPolicyConfiguration , NullPolicyConfiguration , PolicyConfiguration } from 'vs/platform/configuration/common/configurations' ;
1717import { 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' ;
1919import { Registry } from 'vs/platform/registry/common/platform' ;
2020import { IConfigurationRegistry , Extensions , allSettings , windowSettings , resourceSettings , applicationSettings , machineSettings , machineOverridableSettings , ConfigurationScope , IConfigurationPropertySchema , keyFromOverrideIdentifiers , OVERRIDE_PROPERTY_PATTERN , resourceLanguageSettingsSchemaId , configurationDefaultsSchemaId } from 'vs/platform/configuration/common/configurationRegistry' ;
2121import { IStoredWorkspaceFolder , isStoredWorkspaceFolder , IWorkspaceFolderCreationData , getStoredWorkspaceFolder , toWorkspaceFolders } from 'vs/platform/workspaces/common/workspaces' ;
@@ -44,6 +44,7 @@ import { IPolicyService, NullPolicyService } from 'vs/platform/policy/common/pol
4444import { IUserDataProfile , IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile' ;
4545import { IJSONEditingService } from 'vs/workbench/services/configuration/common/jsonEditing' ;
4646import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService' ;
47+ import { workbenchConfigurationNodeBase } from 'vs/workbench/common/configuration' ;
4748
4849function getLocalUserConfigurationScopes ( userDataProfile : IUserDataProfile , hasRemote : boolean ) : ConfigurationScope [ ] | undefined {
4950 return userDataProfile . isDefault
@@ -489,7 +490,11 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
489490 }
490491
491492 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 ) ;
493498 }
494499
495500 private async createWorkspace ( arg : IAnyWorkspaceIdentifier ) : Promise < Workspace > {
@@ -601,6 +606,10 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
601606 const initUserConfiguration = async ( ) => {
602607 mark ( 'code/willInitUserConfiguration' ) ;
603608 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+ }
604613 mark ( 'code/didInitUserConfiguration' ) ;
605614 return result ;
606615 } ;
@@ -714,8 +723,12 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
714723 promises . push ( this . reloadApplicationConfiguration ( true ) ) ;
715724 }
716725 }
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 ) ;
719732 } ) ( ) ) ;
720733 }
721734
@@ -758,15 +771,35 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
758771
759772 private onApplicationConfigurationChanged ( applicationConfiguration : ConfigurationModel ) : void {
760773 const previous = { data : this . _configuration . toData ( ) , workspace : this . workspace } ;
774+ const previousAllProfilesSettings = this . _configuration . applicationConfiguration . getValue < string [ ] > ( APPLY_ALL_PROFILES_SETTING ) ?? [ ] ;
761775 const change = this . _configuration . compareAndUpdateApplicationConfiguration ( applicationConfiguration ) ;
776+ const currentAllProfilesSettings = this . getValue < string [ ] > ( APPLY_ALL_PROFILES_SETTING ) ?? [ ] ;
762777 const configurationProperties = this . configurationRegistry . getConfigurationProperties ( ) ;
763778 const changedKeys : string [ ] = [ ] ;
764779 for ( const changedKey of change . keys ) {
765780 if ( configurationProperties [ changedKey ] ?. scope === ConfigurationScope . APPLICATION ) {
766781 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 ) ;
767797 }
768798 }
769799 change . keys = changedKeys ;
800+ if ( change . keys . includes ( APPLY_ALL_PROFILES_SETTING ) ) {
801+ this . _configuration . updateLocalUserConfiguration ( this . localUserConfiguration . reparse ( { exclude : currentAllProfilesSettings } ) ) ;
802+ }
770803 this . triggerConfigurationChange ( change , previous , ConfigurationTarget . USER ) ;
771804 }
772805
@@ -1318,3 +1351,18 @@ const workbenchContributionsRegistry = Registry.as<IWorkbenchContributionsRegist
13181351workbenchContributionsRegistry . registerWorkbenchContribution ( RegisterConfigurationSchemasContribution , LifecyclePhase . Restored ) ;
13191352workbenchContributionsRegistry . registerWorkbenchContribution ( ResetConfigurationDefaultsOverridesCache , LifecyclePhase . Eventually ) ;
13201353workbenchContributionsRegistry . 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