From 904299951c6b2f4427543a5c712219c9b398c3fd Mon Sep 17 00:00:00 2001 From: Rob Anderson Date: Mon, 19 Jul 2021 14:02:38 +0100 Subject: [PATCH] Fix fetching nested http settings (#511) * Fix fetching nested http settings * fix formatting issue --- .../handlers/settingsHandlers.ts | 9 ++++----- test/settingsHandlers.test.ts | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/languageserver/handlers/settingsHandlers.ts b/src/languageserver/handlers/settingsHandlers.ts index 4e2f5727..ef9dae85 100644 --- a/src/languageserver/handlers/settingsHandlers.ts +++ b/src/languageserver/handlers/settingsHandlers.ts @@ -34,17 +34,16 @@ export class SettingsHandler { async pullConfiguration(): Promise { 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); } diff --git a/test/settingsHandlers.test.ts b/test/settingsHandlers.test.ts index 509c1f21..644dbb3d 100644 --- a/test/settingsHandlers.test.ts +++ b/test/settingsHandlers.test.ts @@ -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: {}, + }); }); }); });