Skip to content

Commit

Permalink
Fix fetching nested http settings (#511)
Browse files Browse the repository at this point in the history
* Fix fetching nested http settings

* fix formatting issue
  • Loading branch information
robb-j authored Jul 19, 2021
1 parent e44fc1b commit 9042999
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
9 changes: 4 additions & 5 deletions src/languageserver/handlers/settingsHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ export class SettingsHandler {
async pullConfiguration(): Promise<void> {
const config = await this.connection.workspace.getConfiguration([
{ section: 'yaml' },
{ section: 'http.proxy' },
{ section: 'http.proxyStrictSSL' },
{ section: 'http' },
{ section: '[yaml]' },
]);
const settings: Settings = {
yaml: config[0],
http: {
proxy: config[1],
proxyStrictSSL: config[2],
proxy: config[1]?.proxy ?? '',
proxyStrictSSL: config[1]?.proxyStrictSSL ?? false,
},
yamlEditor: config[3],
yamlEditor: config[2],
};
this.setConfiguration(settings);
}
Expand Down
18 changes: 10 additions & 8 deletions test/settingsHandlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,21 @@ describe('Settings Handlers Tests', () => {
(validationHandler as unknown) as ValidationHandler,
{} as Telemetry
);
workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]);
workspaceStub.getConfiguration.resolves([{}, {}, {}]);
const setConfigurationStub = sandbox.stub(settingsHandler, 'setConfiguration');

await settingsHandler.pullConfiguration();

expect(workspaceStub.getConfiguration).calledOnceWith([
{ section: 'yaml' },
{ section: 'http.proxy' },
{ section: 'http.proxyStrictSSL' },
{ section: '[yaml]' },
]);
expect(workspaceStub.getConfiguration).calledOnceWith([{ section: 'yaml' }, { section: 'http' }, { section: '[yaml]' }]);

expect(setConfigurationStub).calledOnce;
expect(setConfigurationStub).calledOnceWith({
yaml: {},
http: {
proxy: '',
proxyStrictSSL: false,
},
yamlEditor: {},
});
});
});
});

0 comments on commit 9042999

Please sign in to comment.