Skip to content

Commit

Permalink
Fix crash when handling workspace/didChangeWatchedFiles when project_…
Browse files Browse the repository at this point in the history
…dir not yet set

Fixes #920
  • Loading branch information
lukaszsamson committed Jun 24, 2023
1 parent 34b997a commit cc46f87
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apps/language_server/lib/language_server/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cc46f87

Please sign in to comment.