From 4324b42e60415ece1ae2a149757bede5885d95af Mon Sep 17 00:00:00 2001 From: dvic Date: Mon, 14 Aug 2023 22:34:18 +0200 Subject: [PATCH] fix: coalesce nil start line to 1 Fixes #160 --- lib/next_ls/runtime/sidecar.ex | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/next_ls/runtime/sidecar.ex b/lib/next_ls/runtime/sidecar.ex index c0b0d062..053faa48 100644 --- a/lib/next_ls/runtime/sidecar.ex +++ b/lib/next_ls/runtime/sidecar.ex @@ -15,14 +15,23 @@ defmodule NextLS.Runtime.Sidecar do end def handle_info({:tracer, payload}, state) do + payload = replace_nil(payload, :start_line, 1) DB.insert_symbol(state.db, payload) {:noreply, state} end def handle_info({{:tracer, :reference}, payload}, state) do + payload = replace_nil(payload, :start_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