Fix completion crash on module attribute call (#451)

This commit is contained in:
Jonatan Kłosko 2021-07-16 23:39:51 +02:00 committed by GitHub
parent badbd847dd
commit aa95d81729
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -106,6 +106,10 @@ defmodule Livebook.Completion do
{:ok, List.to_atom(var)}
end
defp expand_dot_path({:module_attribute, _attribute}, _ctx) do
:error
end
defp expand_dot_path({:dot, parent, call}, ctx) do
case expand_dot_path(parent, ctx) do
{:ok, %{} = map} -> Map.fetch(map, List.to_atom(call))

View file

@ -925,4 +925,9 @@ defmodule Livebook.CompletionTest do
}
] = Completion.get_completion_items("@modu", binding, env)
end
test "handles calls on module attribute" do
{binding, env} = eval(do: nil)
assert [] = Completion.get_completion_items("@attr.value", binding, env)
end
end