Skip to content

Commit

Permalink
Keep previous compiler_refs
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaelga committed Sep 27, 2023
1 parent 8a151e1 commit 7648ec3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/next_ls/runtime.ex
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ defmodule NextLS.Runtime do
%{
name: name,
working_dir: working_dir,
compiler_ref: nil,
compiler_refs: %{},
port: port,
task_supervisor: task_supervisor,
logger: logger,
Expand Down Expand Up @@ -224,21 +224,21 @@ defmodule NextLS.Runtime do
end
end)

{:noreply, %{state | compiler_ref: %{task.ref => from}}}
{:noreply, %{state | compiler_refs: Map.put(state.compiler_refs, task.ref, from)}}
end

@impl GenServer
def handle_info({ref, errors}, %{compiler_ref: compiler_ref} = state) when is_map_key(compiler_ref, ref) do
def handle_info({ref, errors}, %{compiler_refs: compiler_refs} = state) when is_map_key(compiler_refs, ref) do
Process.demonitor(ref, [:flush])

GenServer.reply(compiler_ref[ref], errors)
GenServer.reply(compiler_refs[ref], errors)

{:noreply, %{state | compiler_ref: nil}}
{:noreply, %{state | compiler_refs: Map.delete(compiler_refs, ref)}}
end

def handle_info({:DOWN, ref, :process, _pid, _reason}, %{compiler_ref: compiler_ref} = state)
when is_map_key(compiler_ref, ref) do
{:noreply, %{state | compiler_ref: nil}}
def handle_info({:DOWN, ref, :process, _pid, _reason}, %{compiler_refs: compiler_refs} = state)
when is_map_key(compiler_refs, ref) do
{:noreply, %{state | compiler_refs: Map.delete(compiler_refs, ref)}}
end

def handle_info({:DOWN, _, :port, port, _}, %{port: port} = state) do
Expand Down

0 comments on commit 7648ec3

Please sign in to comment.