diff --git a/lib/livebook/intellisense.ex b/lib/livebook/intellisense.ex index e0e01c5e2..fdeea3d22 100644 --- a/lib/livebook/intellisense.ex +++ b/lib/livebook/intellisense.ex @@ -118,6 +118,12 @@ defmodule Livebook.Intellisense do end defp include_in_completion?({:module, _module, _display_name, :hidden}), do: false + + defp include_in_completion?( + {:function, _module, _name, _arity, _display_name, :hidden, _signatures, _specs} + ), + do: false + defp include_in_completion?(_), do: true defp format_completion_item({:variable, name, value}), @@ -201,12 +207,16 @@ defmodule Livebook.Intellisense do insert_text: name } + @ordered_kinds [:field, :variable, :module, :struct, :interface, :function, :type] + + defp completion_item_priority(%{kind: :struct, detail: "exception"} = completion_item) do + {length(@ordered_kinds), completion_item.label} + end + defp completion_item_priority(completion_item) do {completion_item_kind_priority(completion_item.kind), completion_item.label} end - @ordered_kinds [:field, :variable, :module, :struct, :interface, :function, :type] - defp completion_item_kind_priority(kind) when kind in @ordered_kinds do Enum.find_index(@ordered_kinds, &(&1 == kind)) end diff --git a/test/livebook/intellisense_test.exs b/test/livebook/intellisense_test.exs index b234fa5c4..7731058f7 100644 --- a/test/livebook/intellisense_test.exs +++ b/test/livebook/intellisense_test.exs @@ -273,13 +273,6 @@ defmodule Livebook.IntellisenseTest do {binding, env} = eval(do: nil) assert [ - %{ - detail: "Livebook.TestModules.Hidden.hidden()", - documentation: "This is a private API", - insert_text: "hidden()", - kind: :function, - label: "hidden/0" - }, %{ detail: "Livebook.TestModules.Hidden.visible()", documentation: "No documentation available", @@ -287,12 +280,7 @@ defmodule Livebook.IntellisenseTest do kind: :function, label: "visible/0" } - ] = - Intellisense.get_completion_items( - "Livebook.TestModules.Hidden.", - binding, - env - ) + ] = Intellisense.get_completion_items("Livebook.TestModules.Hidden.", binding, env) end test "Elixir root submodule completion" do