File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -1467,7 +1467,11 @@ defmodule ElixirLS.LanguageServer.Server do
14671467 response = JsonRpc . get_configuration_request ( state . root_uri , "elixirLS" )
14681468
14691469 case response do
1470- { :ok , [ result ] } when is_map ( result ) ->
1470+ { :ok , [ result ] } when is_map ( result ) or is_nil ( result ) ->
1471+ # result type is LSPAny, we need to handle at least map and nil
1472+ # https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification/#workspace_configuration
1473+ result = result || % { }
1474+
14711475 Logger . info (
14721476 "Received client configuration via workspace/configuration\n #{ inspect ( result ) } "
14731477 )
Original file line number Diff line number Diff line change @@ -111,6 +111,39 @@ defmodule ElixirLS.LanguageServer.ServerTest do
111111 end )
112112 end
113113
114+ test "handles nil configuration" , % {
115+ server: server
116+ } do
117+ in_fixture ( __DIR__ , "clean" , fn ->
118+ Server . receive_packet (
119+ server ,
120+ initialize_req ( 1 , root_uri ( ) , % {
121+ "workspace" => % {
122+ "configuration" => true
123+ }
124+ } )
125+ )
126+
127+ assert_receive ( % { "id" => 1 , "result" => % { "capabilities" => % { } } } , 1000 )
128+ Server . receive_packet ( server , notification ( "initialized" ) )
129+ uri = root_uri ( )
130+
131+ assert_receive (
132+ % {
133+ "id" => 1 ,
134+ "method" => "workspace/configuration" ,
135+ "params" => % { "items" => [ % { "scopeUri" => ^ uri , "section" => "elixirLS" } ] }
136+ } ,
137+ 1000
138+ )
139+
140+ JsonRpc . receive_packet ( response ( 1 , [ nil ] ) )
141+
142+ assert :sys . get_state ( server ) . mix_env == "test"
143+ wait_until_compiled ( server )
144+ end )
145+ end
146+
114147 test "gets configuration after workspace/didChangeConfiguration notification if client supports it" ,
115148 % {
116149 server: server
You can’t perform that action at this time.
0 commit comments