Skip to content

Commit

Permalink
fix: coalesce nil start line to 1
Browse files Browse the repository at this point in the history
Fixes #160
  • Loading branch information
dvic committed Aug 14, 2023
1 parent d53d8e4 commit 0276343
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/next_ls/runtime/sidecar.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,23 @@ defmodule NextLS.Runtime.Sidecar do
end

def handle_info({:tracer, payload}, state) do
payload = replace_nil(payload, :line, 1)
DB.insert_symbol(state.db, payload)

{:noreply, state}
end

def handle_info({{:tracer, :reference}, payload}, state) do
payload = replace_nil(payload, :line, 1)
DB.insert_reference(state.db, payload)

{:noreply, state}
end

defp replace_nil(data, field, replacement) do
case data do
%{^field => nil} -> %{data | field => replacement}
%{} -> data
end
end
end

0 comments on commit 0276343

Please sign in to comment.