Skip to content

Commit

Permalink
Fire preferences change event on init
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew committed Mar 28, 2023
1 parent 027037b commit b5f4f15
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions packages/plugin-ext/src/hosted/node/plugin-host-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ interface PatchedModules {
}

function createPatchedModules(configProvider: PreferenceRegistryExtImpl, resolveProxy: ReturnType<typeof createProxyResolver>): PatchedModules {
const defaultConfig = 'override' as ProxySupportSetting;
const proxySetting = {
config: configProvider.getConfiguration('http')?.get<ProxySupportSetting>('proxySupport') || 'off' as ProxySupportSetting
config: defaultConfig
};
const certSetting = {
config: false
};
configProvider.onDidChangeConfiguration(() => {
const httpConfig = configProvider.getConfiguration('http');
proxySetting.config = httpConfig?.get<ProxySupportSetting>('proxySupport') || 'off';
proxySetting.config = httpConfig?.get<ProxySupportSetting>('proxySupport') || defaultConfig;
certSetting.config = !!httpConfig?.get<boolean>('systemCertificates');
});

Expand Down
10 changes: 7 additions & 3 deletions packages/plugin-ext/src/plugin/preference-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,16 @@ export class PreferenceRegistryExtImpl implements PreferenceRegistryExt {
}

init(data: PreferenceData): void {
this._preferences = this.parse(data);
this.preferencesChanged(data);
}

$acceptConfigurationChanged(data: PreferenceData, eventData: PreferenceChangeExt[]): void {
this.init(data);
this._onDidChangeConfiguration.fire(this.toConfigurationChangeEvent(eventData));
this.preferencesChanged(data, eventData);
}

private preferencesChanged(data: PreferenceData, eventData?: PreferenceChangeExt[]): void {
this._preferences = this.parse(data);
this._onDidChangeConfiguration.fire(this.toConfigurationChangeEvent(eventData ?? []));
}

getConfiguration(rawSection?: string, rawScope?: theia.ConfigurationScope | null, extensionId?: string): theia.WorkspaceConfiguration {
Expand Down

0 comments on commit b5f4f15

Please sign in to comment.