Skip to content

Commit 29766b8

Browse files
committed
Ensure that all commands include the server instance id
Will help prevent needing to fix bugs like: elixir-lsp#505
1 parent 216144b commit 29766b8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

apps/language_server/test/server_test.exs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,24 @@ defmodule ElixirLS.LanguageServer.ServerTest do
4646
assert_receive(%{"id" => 1, "result" => %{"capabilities" => %{}}}, 1000)
4747
end
4848

49+
test "Execute commands should include the server instance id", %{server: server} do
50+
# If a command does not include the server instance id then it will cause
51+
# vscode-elixir-ls to fail to start up on multi-root workspaces.
52+
# Example: https://github.com/elixir-lsp/elixir-ls/pull/505
53+
54+
Server.receive_packet(server, initialize_req(1, root_uri(), %{}))
55+
assert_receive(%{"id" => 1, "result" => all = %{"capabilities" => capabilities}}, 1000)
56+
57+
commands = get_in(capabilities, ["executeCommandProvider", "commands"])
58+
server_instance_id = :sys.get_state(server).server_instance_id
59+
60+
Enum.each(commands, fn command ->
61+
assert String.contains?(command, server_instance_id)
62+
end)
63+
64+
refute Enum.empty?(commands)
65+
end
66+
4967
test "returns -32600 InvalidRequest when already initialized", %{server: server} do
5068
Server.receive_packet(server, initialize_req(1, root_uri(), %{}))
5169
assert_receive(%{"id" => 1, "result" => %{"capabilities" => %{}}}, 1000)

0 commit comments

Comments
 (0)