Skip to content

Commit cc46f87

Browse files
committed
Fix crash when handling workspace/didChangeWatchedFiles when project_dir not yet set
Fixes #920
1 parent 34b997a commit cc46f87

File tree

1 file changed

+7
-1
lines changed
  • apps/language_server/lib/language_server

1 file changed

+7
-1
lines changed

apps/language_server/lib/language_server/server.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@ defmodule ElixirLS.LanguageServer.Server do
418418
end
419419
end
420420

421-
defp handle_notification(did_change_watched_files(changes), state = %__MODULE__{}) do
421+
defp handle_notification(did_change_watched_files(changes), state = %__MODULE__{})
422+
when is_binary(state.project_dir) do
422423
changes = Enum.filter(changes, &match?(%{"uri" => "file:" <> _}, &1))
423424

424425
# `settings` may not always be available here, like during testing
@@ -486,6 +487,11 @@ defmodule ElixirLS.LanguageServer.Server do
486487
if needs_build, do: trigger_build(state), else: state
487488
end
488489

490+
defp handle_notification(did_change_watched_files(_changes), state = %__MODULE__{}) do
491+
# swallow notification if project_dir is not yet set
492+
state
493+
end
494+
489495
defp handle_notification(%{"method" => "$/" <> _}, state = %__MODULE__{}) do
490496
# not supported "$/" notifications may be safely ignored
491497
state

0 commit comments

Comments
 (0)