@@ -1333,33 +1333,42 @@ class RegisterConfigurationSchemasContribution extends Disposable implements IWo
1333
1333
}
1334
1334
}
1335
1335
1336
- class ResetConfigurationDefaultsOverridesCache extends Disposable implements IWorkbenchContribution {
1337
- constructor (
1338
- @IConfigurationService configurationService : WorkspaceService ,
1339
- @IExtensionService extensionService : IExtensionService ,
1340
- ) {
1341
- super ( ) ;
1342
- if ( configurationService . hasCachedConfigurationDefaultsOverrides ( ) ) {
1343
- extensionService . whenInstalledExtensionsRegistered ( ) . then ( ( ) => configurationService . reloadConfiguration ( ConfigurationTarget . DEFAULT ) ) ;
1344
- }
1345
- }
1346
- }
1336
+ class ConfigurationDefaultOverridesContribution extends Disposable implements IWorkbenchContribution {
1347
1337
1348
- class UpdateExperimentalSettingsDefaults extends Disposable implements IWorkbenchContribution {
1349
-
1350
- static readonly ID = 'workbench.contrib.updateExperimentalSettingsDefaults' ;
1338
+ static readonly ID = 'workbench.contrib.configurationDefaultOverridesContribution' ;
1351
1339
1352
1340
private readonly processedExperimentalSettings = new Set < string > ( ) ;
1353
1341
private readonly configurationRegistry = Registry . as < IConfigurationRegistry > ( Extensions . Configuration ) ;
1354
1342
1355
1343
constructor (
1356
- @IWorkbenchAssignmentService private readonly workbenchAssignmentService : IWorkbenchAssignmentService
1344
+ @IWorkbenchAssignmentService private readonly workbenchAssignmentService : IWorkbenchAssignmentService ,
1345
+ @IExtensionService private readonly extensionService : IExtensionService ,
1346
+ @IConfigurationService private readonly configurationService : WorkspaceService ,
1347
+ @ILogService private readonly logService : ILogService
1357
1348
) {
1358
1349
super ( ) ;
1359
- this . processExperimentalSettings ( Object . keys ( this . configurationRegistry . getConfigurationProperties ( ) ) ) ;
1350
+
1351
+ this . updateDefaults ( ) ;
1352
+
1353
+ // When configuration is updated make sure to apply experimental configuration overrides
1360
1354
this . _register ( this . configurationRegistry . onDidUpdateConfiguration ( ( { properties } ) => this . processExperimentalSettings ( properties ) ) ) ;
1361
1355
}
1362
1356
1357
+ private async updateDefaults ( ) : Promise < void > {
1358
+ this . logService . trace ( 'ConfigurationService#updateDefaults: begin' ) ;
1359
+ try {
1360
+ // Check for experiments
1361
+ await this . processExperimentalSettings ( Object . keys ( this . configurationRegistry . getConfigurationProperties ( ) ) ) ;
1362
+ } finally {
1363
+ // Invalidate defaults cache after extensions have registered
1364
+ // and after the experiments have been resolved to prevent
1365
+ // resetting the overrides too early.
1366
+ await this . extensionService . whenInstalledExtensionsRegistered ( ) ;
1367
+ this . logService . trace ( 'ConfigurationService#updateDefaults: resetting the defaults' ) ;
1368
+ this . configurationService . reloadConfiguration ( ConfigurationTarget . DEFAULT ) ;
1369
+ }
1370
+ }
1371
+
1363
1372
private async processExperimentalSettings ( properties : Iterable < string > ) : Promise < void > {
1364
1373
const overrides : IStringDictionary < any > = { } ;
1365
1374
const allProperties = this . configurationRegistry . getConfigurationProperties ( ) ;
@@ -1391,8 +1400,7 @@ class UpdateExperimentalSettingsDefaults extends Disposable implements IWorkbenc
1391
1400
1392
1401
const workbenchContributionsRegistry = Registry . as < IWorkbenchContributionsRegistry > ( WorkbenchExtensions . Workbench ) ;
1393
1402
workbenchContributionsRegistry . registerWorkbenchContribution ( RegisterConfigurationSchemasContribution , LifecyclePhase . Restored ) ;
1394
- workbenchContributionsRegistry . registerWorkbenchContribution ( ResetConfigurationDefaultsOverridesCache , LifecyclePhase . Eventually ) ;
1395
- registerWorkbenchContribution2 ( UpdateExperimentalSettingsDefaults . ID , UpdateExperimentalSettingsDefaults , WorkbenchPhase . BlockRestore ) ;
1403
+ registerWorkbenchContribution2 ( ConfigurationDefaultOverridesContribution . ID , ConfigurationDefaultOverridesContribution , WorkbenchPhase . BlockRestore ) ;
1396
1404
1397
1405
const configurationRegistry = Registry . as < IConfigurationRegistry > ( Extensions . Configuration ) ;
1398
1406
configurationRegistry . registerConfiguration ( {
0 commit comments