Skip to content

Commit 9042999

Browse files
authored
Fix fetching nested http settings (redhat-developer#511)
* Fix fetching nested http settings * fix formatting issue
1 parent e44fc1b commit 9042999

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/languageserver/handlers/settingsHandlers.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,16 @@ export class SettingsHandler {
3434
async pullConfiguration(): Promise<void> {
3535
const config = await this.connection.workspace.getConfiguration([
3636
{ section: 'yaml' },
37-
{ section: 'http.proxy' },
38-
{ section: 'http.proxyStrictSSL' },
37+
{ section: 'http' },
3938
{ section: '[yaml]' },
4039
]);
4140
const settings: Settings = {
4241
yaml: config[0],
4342
http: {
44-
proxy: config[1],
45-
proxyStrictSSL: config[2],
43+
proxy: config[1]?.proxy ?? '',
44+
proxyStrictSSL: config[1]?.proxyStrictSSL ?? false,
4645
},
47-
yamlEditor: config[3],
46+
yamlEditor: config[2],
4847
};
4948
this.setConfiguration(settings);
5049
}

test/settingsHandlers.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,21 @@ describe('Settings Handlers Tests', () => {
156156
(validationHandler as unknown) as ValidationHandler,
157157
{} as Telemetry
158158
);
159-
workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]);
159+
workspaceStub.getConfiguration.resolves([{}, {}, {}]);
160160
const setConfigurationStub = sandbox.stub(settingsHandler, 'setConfiguration');
161161

162162
await settingsHandler.pullConfiguration();
163163

164-
expect(workspaceStub.getConfiguration).calledOnceWith([
165-
{ section: 'yaml' },
166-
{ section: 'http.proxy' },
167-
{ section: 'http.proxyStrictSSL' },
168-
{ section: '[yaml]' },
169-
]);
164+
expect(workspaceStub.getConfiguration).calledOnceWith([{ section: 'yaml' }, { section: 'http' }, { section: '[yaml]' }]);
170165

171-
expect(setConfigurationStub).calledOnce;
166+
expect(setConfigurationStub).calledOnceWith({
167+
yaml: {},
168+
http: {
169+
proxy: '',
170+
proxyStrictSSL: false,
171+
},
172+
yamlEditor: {},
173+
});
172174
});
173175
});
174176
});

0 commit comments

Comments
 (0)