Skip to content

List all workspace symbols when an empty query comes in #603

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

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,8 @@ defmodule ElixirLS.LanguageServer.Providers.WorkspaceSymbols do
end

defp query(query, server) do
case String.trim(query) do
"" ->
[]

trimmed ->
GenServer.call(server, {:query, trimmed})
end
trimmed = String.trim(query)
GenServer.call(server, {:query, trimmed})
end

defp index(module_paths) do
Expand Down Expand Up @@ -437,6 +432,11 @@ defmodule ElixirLS.LanguageServer.Providers.WorkspaceSymbols do
:ok
end

@spec get_results(state_t, String.t()) :: [symbol_information_t]
defp get_results(state, "") do
(state.modules ++ state.functions ++ state.types ++ state.callbacks)
end

@spec get_results(state_t, String.t()) :: [symbol_information_t]
defp get_results(state, query) do
query_downcase = String.downcase(query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ defmodule ElixirLS.LanguageServer.Providers.WorkspaceSymbolsTest do
end

test "empty query", %{server: server} do
assert {:ok, []} == WorkspaceSymbols.symbols("", server)
{status, all_symbols} = WorkspaceSymbols.symbols("", server)
assert :ok == status
assert 11 == length(all_symbols)

assert_receive %{
"method" => "window/logMessage",
Expand Down