Skip to content

Commit 9d13ba8

Browse files
committed
(GH-177) Move warning due to initialized notification
While technically the protocol does allow the server to send window/showMessage notifcations during initialization, it's better to send the warning at the end of initialization i.e. at the initialized notification.
1 parent 00f7548 commit 9d13ba8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/puppet-languageserver/message_router.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ def receive_request(request)
4747
PuppetLanguageServer.log_message(:debug, 'Received initialize method')
4848
client.parse_lsp_initialize!(request.params)
4949
request.reply_result('capabilities' => PuppetLanguageServer::ServerCapabilites.capabilities)
50-
unless server_options[:puppet_version].nil? || server_options[:puppet_version] == Puppet.version
51-
# Add a minor delay before sending the notification to give the client some processing time
52-
sleep(0.5)
53-
json_rpc_handler.send_show_message_notification(
54-
LSP::MessageType::WARNING,
55-
"Unable to use Puppet version '#{server_options[:puppet_version]}' as it is not available. Using version '#{Puppet.version}' instead."
56-
)
57-
end
5850

5951
when 'shutdown'
6052
PuppetLanguageServer.log_message(:debug, 'Received shutdown method')
@@ -253,6 +245,14 @@ def receive_notification(method, params)
253245
case method
254246
when 'initialized'
255247
PuppetLanguageServer.log_message(:info, 'Client has received initialization')
248+
# Raise a warning if the Puppet version is mismatched
249+
unless server_options[:puppet_version].nil? || server_options[:puppet_version] == Puppet.version
250+
json_rpc_handler.send_show_message_notification(
251+
LSP::MessageType::WARNING,
252+
"Unable to use Puppet version '#{server_options[:puppet_version]}' as it is not available. Using version '#{Puppet.version}' instead."
253+
)
254+
end
255+
# Register for workspace setting changes if it's supported
256256
if client.client_capability('workspace', 'didChangeConfiguration', 'dynamicRegistration') == true
257257
client.register_capability('workspace/didChangeConfiguration')
258258
else

0 commit comments

Comments
 (0)