Skip to content

Commit

Permalink
fix: use first reference with go to definition (#137)
Browse files Browse the repository at this point in the history
when the compiler is tracing macros, the actual source code gets
expanded first and that is what we want, later, it will trace the
expanded code, and it will exist in ranges that overlap with the actual
source code.

I believe we can rely on the integer id being lower for the first one,
and use an order by clause.
  • Loading branch information
mhanberg authored Aug 1, 2023
1 parent bf1869c commit e3ed704
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
17 changes: 0 additions & 17 deletions lib/next_ls/db.ex
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,6 @@ defmodule NextLS.DB do
{{meta[:line], col},
{meta[:line], col + String.length(identifier |> to_string() |> String.replace("Elixir.", ""))}}

__query__(
{conn, s.logger},
~Q"""
DELETE FROM 'references' AS refs
WHERE refs.file = ?
AND (? <= refs.start_line
AND refs.start_line <= ?
AND ? <= refs.start_column
AND refs.start_column <= ?)
OR (? <= refs.end_line
AND refs.end_line <= ?
AND ? <= refs.end_column
AND refs.end_column <= ?);
""",
[file, start_line, end_line, start_column, end_column, start_line, end_line, start_column, end_column]
)

__query__(
{conn, s.logger},
~Q"""
Expand Down
3 changes: 1 addition & 2 deletions lib/next_ls/definition.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ defmodule NextLS.Definition do
AND ? <= refs.end_line
AND refs.start_column <= ?
AND ? <= refs.end_column
ORDER BY refs.id desc
ORDER BY refs.id asc
LIMIT 1;
""",
[file, line, line, col, col]
) do
Expand Down

0 comments on commit e3ed704

Please sign in to comment.