Skip to content

Ensure that all commands include the server instance id #507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions apps/language_server/test/server_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ defmodule ElixirLS.LanguageServer.ServerTest do
assert_receive(%{"id" => 1, "result" => %{"capabilities" => %{}}}, 1000)
end

test "Execute commands should include the server instance id", %{server: server} do
# If a command does not include the server instance id then it will cause
# vscode-elixir-ls to fail to start up on multi-root workspaces.
# Example: https://github.com/elixir-lsp/elixir-ls/pull/505

Server.receive_packet(server, initialize_req(1, root_uri(), %{}))
assert_receive(%{"id" => 1, "result" => result}, 1000)

commands = get_in(result, ["capabilities", "executeCommandProvider", "commands"])
server_instance_id = :sys.get_state(server).server_instance_id

Enum.each(commands, fn command ->
assert String.contains?(command, server_instance_id)
end)

refute Enum.empty?(commands)
end

test "returns -32600 InvalidRequest when already initialized", %{server: server} do
Server.receive_packet(server, initialize_req(1, root_uri(), %{}))
assert_receive(%{"id" => 1, "result" => %{"capabilities" => %{}}}, 1000)
Expand Down