Skip to content

Commit b010218

Browse files
committed
fix: update client support function to match the configuration shate
The previous function claimed to return a boolean, but given the nested nature of the configuration struct, it's more useful to make it return whatever is stored instead
1 parent b237fd5 commit b010218

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

apps/expert/lib/expert/configuration.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ defmodule Expert.Configuration do
5353
:persistent_term.get(__MODULE__, false) || new()
5454
end
5555

56-
@spec client_supports?(atom()) :: boolean()
57-
def client_supports?(key) when is_atom(key) do
58-
client_supports?(get().support, key)
56+
@spec client_support(atom()) :: term()
57+
def client_support(key) when is_atom(key) do
58+
client_support(get().support, key)
5959
end
6060

61-
defp client_supports?(%Support{} = client_support, key) do
61+
defp client_support(%Support{} = client_support, key) do
6262
case Map.fetch(client_support, key) do
6363
{:ok, value} -> value
6464
:error -> raise ArgumentError, "unknown key: #{inspect(key)}"

apps/expert/lib/expert/project/progress/state.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ defmodule Expert.Project.Progress.State do
9090
end
9191

9292
defp write_work_done(lsp, token) do
93-
if Configuration.client_supports?(:work_done_progress) do
93+
if Configuration.client_support(:work_done_progress) == true do
9494
GenLSP.request(lsp, %Requests.WindowWorkDoneProgressCreate{
9595
id: Id.next(),
9696
params: %Structures.WorkDoneProgressCreateParams{token: token}
@@ -99,7 +99,7 @@ defmodule Expert.Project.Progress.State do
9999
end
100100

101101
defp write(lsp, %progress_module{token: token} = progress) when not is_nil(token) do
102-
if Configuration.client_supports?(:work_done_progress) do
102+
if Configuration.client_support(:work_done_progress) == true do
103103
GenLSP.notify(
104104
lsp,
105105
progress_module.to_protocol(progress)

apps/expert/test/expert/project/progress_test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ defmodule Expert.Project.ProgressTest do
5959
end
6060

6161
def with_work_done_progress_support(_) do
62-
patch(Configuration, :client_supports?, fn :work_done_progress -> true end)
62+
patch(Configuration, :client_support, fn :work_done_progress -> true end)
6363
:ok
6464
end
6565

6666
describe "report the progress message" do
6767
setup [:with_patched_transport]
6868

6969
test "it should be able to send the report progress", %{project: project} do
70-
patch(Configuration, :client_supports?, fn :work_done_progress -> true end)
70+
patch(Configuration, :client_support, fn :work_done_progress -> true end)
7171

7272
begin_message = progress(:begin, "mix compile")
7373
EngineApi.broadcast(project, begin_message)
@@ -94,7 +94,7 @@ defmodule Expert.Project.ProgressTest do
9494
end
9595

9696
test "it should write nothing when the client does not support work done", %{project: project} do
97-
patch(Configuration, :client_supports?, fn :work_done_progress -> false end)
97+
patch(Configuration, :client_support, fn :work_done_progress -> false end)
9898

9999
begin_message = progress(:begin, "mix compile")
100100
EngineApi.broadcast(project, begin_message)

0 commit comments

Comments
 (0)