Skip to content

Commit

Permalink
add logs (#167847)
Browse files Browse the repository at this point in the history
add logs #163418
  • Loading branch information
sandy081 authored Dec 2, 2022
1 parent 5457383 commit cb226f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/vs/platform/configuration/common/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ export class PolicyConfiguration extends Disposable implements IPolicyConfigurat
}

async initialize(): Promise<ConfigurationModel> {
this.logService.trace('PolicyConfiguration#initialize');
this.update(await this.updatePolicyDefinitions(this.defaultConfiguration.configurationModel.keys), false);
this._register(this.policyService.onDidChange(policyNames => this.onDidChangePolicies(policyNames)));
this._register(this.defaultConfiguration.onDidChangeConfiguration(async ({ properties }) => this.update(await this.updatePolicyDefinitions(properties), true)));
return this._configurationModel;
}

private async updatePolicyDefinitions(properties: string[]): Promise<string[]> {
this.logService.trace('PolicyConfiguration#updatePolicyDefinitions', properties);
const policyDefinitions: IStringDictionary<PolicyDefinition> = {};
const keys: string[] = [];
const configurationProperties = Registry.as<IConfigurationRegistry>(Extensions.Configuration).getConfigurationProperties();
Expand Down Expand Up @@ -143,12 +145,14 @@ export class PolicyConfiguration extends Disposable implements IPolicyConfigurat
}

private onDidChangePolicies(policyNames: readonly PolicyName[]): void {
this.logService.trace('PolicyConfiguration#onDidChangePolicies', policyNames);
const policyConfigurations = Registry.as<IConfigurationRegistry>(Extensions.Configuration).getPolicyConfigurations();
const keys = coalesce(policyNames.map(policyName => policyConfigurations.get(policyName)));
this.update(keys, true);
}

private update(keys: string[], trigger: boolean): void {
this.logService.trace('PolicyConfiguration#update', keys);
const configurationProperties = Registry.as<IConfigurationRegistry>(Extensions.Configuration).getConfigurationProperties();
const changed: [string, PolicyValue | undefined][] = [];
const wasEmpty = this._configurationModel.isEmpty();
Expand All @@ -168,6 +172,7 @@ export class PolicyConfiguration extends Disposable implements IPolicyConfigurat
}

if (changed.length) {
this.logService.trace('PolicyConfiguration#changed', changed);
const old = this._configurationModel;
this._configurationModel = new ConfigurationModel();
for (const key of old.keys) {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/policy/common/filePolicyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { AbstractPolicyService, IPolicyService, PolicyName, PolicyValue } from '
function keysDiff<T>(a: Map<string, T>, b: Map<string, T>): string[] {
const result: string[] = [];

for (const key of Iterable.concat(a.keys(), b.keys())) {
for (const key of new Set(Iterable.concat(a.keys(), b.keys()))) {
if (a.get(key) !== b.get(key)) {
result.push(key);
}
Expand Down

0 comments on commit cb226f7

Please sign in to comment.