Skip to content

Commit

Permalink
Fix Elixir root module completion
Browse files Browse the repository at this point in the history
Fixes #230
  • Loading branch information
Goose97 committed Jul 13, 2023
1 parent 1166a2f commit c927431
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/elixir_sense/providers/suggestion/complete.ex
Original file line number Diff line number Diff line change
Expand Up @@ -542,14 +542,19 @@ defmodule ElixirSense.Providers.Suggestion.Complete do
depth = length(String.split(name, ".")) + 1
base = name <> "." <> hint

concat_module = fn
["Elixir", "Elixir" | _] = parts -> parts |> tl() |> Module.concat()
parts -> Module.concat(parts)
end

for mod <- match_modules(base, module === Elixir, env),
mod_as_atom = mod |> String.to_atom(),
filter.(mod_as_atom),
parts = String.split(mod, "."),
depth <= length(parts),
name = Enum.at(parts, depth - 1),
valid_alias_piece?("." <> name),
concatted = parts |> Enum.take(depth) |> Module.concat(),
concatted = parts |> Enum.take(depth) |> concat_module.(),
filter.(concatted) do
{name, concatted, false}
end
Expand Down
2 changes: 1 addition & 1 deletion test/elixir_sense/providers/suggestion/complete_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ defmodule ElixirSense.Providers.Suggestion.CompleteTest do

test "elixir proxy" do
list = expand(~c"E")
assert list |> Enum.find(&(&1.name == "Elixir" and &1.full_name == "Elixir.Elixir"))
assert list |> Enum.find(&(&1.name == "Elixir" and &1.full_name == "Elixir"))
end

test "elixir completion" do
Expand Down
2 changes: 1 addition & 1 deletion test/elixir_sense/suggestions_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1976,7 +1976,7 @@ defmodule ElixirSense.SuggestionsTest do
assert %{
type: :module,
name: "Elixir",
full_name: "Elixir.Elixir",
full_name: "Elixir",
subtype: nil,
summary: "",
metadata: %{}
Expand Down

0 comments on commit c927431

Please sign in to comment.