diff --git a/lib/next_ls/db.ex b/lib/next_ls/db.ex index 564598c0..3a356df6 100644 --- a/lib/next_ls/db.ex +++ b/lib/next_ls/db.ex @@ -174,7 +174,7 @@ defmodule NextLS.DB do def __query__({conn, logger}, query, args) do args = Enum.map(args, &cast/1) - with {:error, _e} <- :esqlite3.q(conn, query, cast(args)) do + with {:error, _e} <- :esqlite3.q(conn, query, args) do error = :esqlite3.error_info(conn).errmsg NextLS.Logger.error(logger, error) {:error, error} diff --git a/lib/next_ls/definition.ex b/lib/next_ls/definition.ex index bdd94c12..36d69c8a 100644 --- a/lib/next_ls/definition.ex +++ b/lib/next_ls/definition.ex @@ -18,7 +18,10 @@ defmodule NextLS.Definition do AND refs.start_line <= ? AND ? <= refs.end_line AND refs.start_column <= ? - AND ? <= refs.end_column; + AND ? <= refs.end_column + ORDER BY refs.id desc + LIMIT 1; + """, [file, line, line, col, col] )