Skip to content

Skip non file: URI scheme notifications #475

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
merged 1 commit into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions apps/language_server/lib/language_server/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,13 @@ defmodule ElixirLS.LanguageServer.Server do
end

defp handle_notification(did_change_watched_files(changes), state) do
changes = Enum.filter(changes, &match?(%{"uri" => "file:" <> _}, &1))

needs_build =
Enum.any?(changes, fn %{"uri" => uri, "type" => type} ->
Path.extname(uri) in @watched_extensions and
Enum.any?(changes, fn %{"uri" => uri = "file:" <> _, "type" => type} ->
path = SourceFile.path_from_uri(uri)

Path.extname(path) in @watched_extensions and
(type in [1, 3] or not Map.has_key?(state.source_files, uri) or
state.source_files[uri].dirty?)
end)
Expand Down Expand Up @@ -422,6 +426,7 @@ defmodule ElixirLS.LanguageServer.Server do
end

_ ->
# file not open or not dirty
acc
end
end)
Expand Down
12 changes: 12 additions & 0 deletions apps/language_server/test/server_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,18 @@ defmodule ElixirLS.LanguageServer.ServerTest do
state = :sys.get_state(server)
assert state.needs_build?
end

test "gracefully skip not supported URI scheme", %{server: server} do
uri = "git://github.com/user/repo.git"
fake_initialize(server)

Server.receive_packet(
server,
did_change_watched_files([%{"uri" => uri, "type" => 2}])
)

:sys.get_state(server)
end
end

test "hover", %{server: server} do
Expand Down