Skip to content

Commit

Permalink
Improve aliased struct completions (#232)
Browse files Browse the repository at this point in the history
This PR allows aliased struct to be completed with %. It does so by correcting the subtype of the suggestion.

Fixes #229
  • Loading branch information
Goose97 committed Jun 29, 2023
1 parent a50b8b6 commit c733dc8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/elixir_sense/providers/suggestion/complete.ex
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ defmodule ElixirSense.Providers.Suggestion.Complete do
name: name,
full_name: inspect(mod),
desc: {"", %{}},
subtype: nil
subtype: Introspection.get_module_subtype(mod)
}
end
end
Expand Down
7 changes: 7 additions & 0 deletions test/elixir_sense/providers/suggestion/complete_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,13 @@ defmodule ElixirSense.Providers.Suggestion.CompleteTest do
assert entries |> Enum.any?(&(&1.name == "URI"))

assert [%{name: "MyStruct"}] = expand('%ElixirSense.Providers.Suggestion.CompleteTest.')

env = %Env{
aliases: [{MyDate, Date}]
}

entries = expand('%My', env, required_alias: true)
assert Enum.any?(entries, &(&1.name == "MyDate" and &1.subtype == :struct))
end

@tag requires_elixir_1_14: true
Expand Down

0 comments on commit c733dc8

Please sign in to comment.