Skip to content

Commit 00f7548

Browse files
committed
(GH-177) Fix workspace/configuration settings hash
Previously the settings were passed directly from the response into the client for processing however this does not emulate the legacy settings hash. This commit adds the original scope onto the settings hash so it appears like the legacy hash e.g. puppet.editorservices.abc instead of editorserivces.abc
1 parent b0e3a67 commit 00f7548

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/puppet-languageserver/message_router.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,10 @@ def receive_response(response, original_request)
325325
client.parse_unregister_capability_response!(response, original_request)
326326
when 'workspace/configuration'
327327
return unless receive_response_succesful?(response)
328-
client.parse_lsp_configuration_settings!(response['result'])
328+
original_request['params'].items.each_with_index do |item, index|
329+
# The response from the client strips the section name so we need to re-add it
330+
client.parse_lsp_configuration_settings!(item.section => response['result'][index])
331+
end
329332
else
330333
super
331334
end

spec/languageserver/unit/puppet-languageserver/message_router_spec.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,12 +1123,16 @@
11231123
end
11241124

11251125
context 'given an original workspace/configuration request' do
1126-
let(:response_result) { { 'setting1' => 'value1' } }
1126+
let(:response_result) { [{ 'setting1' => 'value1' }] }
11271127
let(:request_method) { 'workspace/configuration'}
1128-
let(:request_params) { {} }
1128+
let(:request_params) do
1129+
params = LSP::ConfigurationParams.new.from_h!('items' => [])
1130+
params.items << LSP::ConfigurationItem.new.from_h!('section' => 'mock')
1131+
params
1132+
end
11291133

11301134
it 'should call client.parse_lsp_configuration_settings!' do
1131-
expect(subject.client).to receive(:parse_lsp_configuration_settings!).with(response_result)
1135+
expect(subject.client).to receive(:parse_lsp_configuration_settings!).with({ 'mock' => response_result[0] })
11321136

11331137
subject.receive_response(response, original_request)
11341138
end

0 commit comments

Comments
 (0)