Skip to content

Commit

Permalink
CAT-1670 - Fix undefined variable json_rpc_handler
Browse files Browse the repository at this point in the history
Prior to this commit, we would see in the language server logs that we
were referencing an undefined variable `json_rpc_handler`.

This had knock on effects, such as registering the onTypeformatting
provider, meaning this setting would not work when enabled.

We now update the json_rpc_handler send message event to be consistent
with the rest of the language server, and to fix the undefined variable
error.

The dynamically registered providers, like onTypeFormatting, will now
work as expected.
  • Loading branch information
jordanbreen28 committed Apr 24, 2024
1 parent f36499a commit d6d0825
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/puppet-languageserver/message_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,13 @@ def notification_initialized(_, _json_rpc_message)
# Raise a warning if the Puppet version is mismatched
server_options = protocol.connection.server.server_options
unless server_options[:puppet_version].nil? || server_options[:puppet_version] == Puppet.version
json_rpc_handler.send_show_message_notification(
LSP::MessageType::WARNING,
"Unable to use Puppet version '#{server_options[:puppet_version]}' as it is not available. Using version '#{Puppet.version}' instead."
protocol.encode_and_send(
::PuppetEditorServices::Protocol::JsonRPCMessages.new_notification(

Check failure on line 304 in lib/puppet-languageserver/message_handler.rb

View workflow job for this annotation

GitHub Actions / Spec : ubuntu-latest Ruby 2.7 / spec

Layout/FirstArgumentIndentation: Indent the first argument one step more than the start of the previous line.

Check failure on line 304 in lib/puppet-languageserver/message_handler.rb

View workflow job for this annotation

GitHub Actions / Spec : windows-latest Ruby 2.7 / spec

Layout/FirstArgumentIndentation: Indent the first argument one step more than the start of the previous line.

Check failure on line 304 in lib/puppet-languageserver/message_handler.rb

View workflow job for this annotation

GitHub Actions / Spec : ubuntu-latest Ruby 3.2 / spec

Layout/FirstArgumentIndentation: Indent the first argument one step more than the start of the previous line.

Check failure on line 304 in lib/puppet-languageserver/message_handler.rb

View workflow job for this annotation

GitHub Actions / Spec : windows-latest Ruby 3.2 / spec

Layout/FirstArgumentIndentation: Indent the first argument one step more than the start of the previous line.
'window/showMessage',
'type' => LSP::MessageType::WARNING,
'message' => "Unable to use Puppet version '#{server_options[:puppet_version]}' as it is not available. Using version '#{Puppet.version}' instead."
)
)
end

# Register for workspace setting changes if it's supported
Expand Down

0 comments on commit d6d0825

Please sign in to comment.