Skip to content

Commit 0276343

Browse files
committed
fix: coalesce nil start line to 1
Fixes #160
1 parent d53d8e4 commit 0276343

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/next_ls/runtime/sidecar.ex

+9
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,23 @@ defmodule NextLS.Runtime.Sidecar do
1515
end
1616

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

2021
{:noreply, state}
2122
end
2223

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

2628
{:noreply, state}
2729
end
30+
31+
defp replace_nil(data, field, replacement) do
32+
case data do
33+
%{^field => nil} -> %{data | field => replacement}
34+
%{} -> data
35+
end
36+
end
2837
end

0 commit comments

Comments
 (0)