diff --git a/apps/language_server/lib/language_server/server.ex b/apps/language_server/lib/language_server/server.ex index 0ad4aea0e..8a7223a80 100644 --- a/apps/language_server/lib/language_server/server.ex +++ b/apps/language_server/lib/language_server/server.ex @@ -418,7 +418,8 @@ defmodule ElixirLS.LanguageServer.Server do end end - defp handle_notification(did_change_watched_files(changes), state = %__MODULE__{}) do + defp handle_notification(did_change_watched_files(changes), state = %__MODULE__{}) + when is_binary(state.project_dir) do changes = Enum.filter(changes, &match?(%{"uri" => "file:" <> _}, &1)) # `settings` may not always be available here, like during testing @@ -486,6 +487,11 @@ defmodule ElixirLS.LanguageServer.Server do if needs_build, do: trigger_build(state), else: state end + defp handle_notification(did_change_watched_files(_changes), state = %__MODULE__{}) do + # swallow notification if project_dir is not yet set + state + end + defp handle_notification(%{"method" => "$/" <> _}, state = %__MODULE__{}) do # not supported "$/" notifications may be safely ignored state