Skip to content

Commit 8d856e5

Browse files
authored
workbench.secondarySideBar.defaultVisibility does not work well with new user data dir (fix microsoft#252505) (microsoft#252966)
* workbench.secondarySideBar.defaultVisibility does not work well with new user data dir (fix microsoft#252505) * add logging
1 parent 86a8f0d commit 8d856e5

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

src/vs/workbench/services/configuration/browser/configurationService.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,33 +1333,42 @@ class RegisterConfigurationSchemasContribution extends Disposable implements IWo
13331333
}
13341334
}
13351335

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 {
13471337

1348-
class UpdateExperimentalSettingsDefaults extends Disposable implements IWorkbenchContribution {
1349-
1350-
static readonly ID = 'workbench.contrib.updateExperimentalSettingsDefaults';
1338+
static readonly ID = 'workbench.contrib.configurationDefaultOverridesContribution';
13511339

13521340
private readonly processedExperimentalSettings = new Set<string>();
13531341
private readonly configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
13541342

13551343
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
13571348
) {
13581349
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
13601354
this._register(this.configurationRegistry.onDidUpdateConfiguration(({ properties }) => this.processExperimentalSettings(properties)));
13611355
}
13621356

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+
13631372
private async processExperimentalSettings(properties: Iterable<string>): Promise<void> {
13641373
const overrides: IStringDictionary<any> = {};
13651374
const allProperties = this.configurationRegistry.getConfigurationProperties();
@@ -1391,8 +1400,7 @@ class UpdateExperimentalSettingsDefaults extends Disposable implements IWorkbenc
13911400

13921401
const workbenchContributionsRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
13931402
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);
13961404

13971405
const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
13981406
configurationRegistry.registerConfiguration({

0 commit comments

Comments
 (0)