Skip to content

Commit

Permalink
fix: check if cursor is on definition(#1042)
Browse files Browse the repository at this point in the history
  • Loading branch information
shinohara-rin committed May 6, 2024
1 parent a4809ce commit 7958ff2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion apps/language_server/lib/language_server/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,18 @@ defmodule ElixirLS.LanguageServer.Server do
fun = fn ->
{line, character} = SourceFile.lsp_position_to_elixir(source_file.text, {line, character})
parser_context = Parser.parse_immediate(uri, source_file, {line, character})
Definition.definition(uri, parser_context, line, character, state.project_dir)

{:ok, result} =
Definition.definition(uri, parser_context, line, character, state.project_dir)

if result.uri == uri && result.range["start"]["line"] == line - 1 do
case References.references(parser_context, uri, line, character, false, state.project_dir) do
[] -> {:ok, result}
refs -> {:ok, refs}
end
else
{:ok, result}
end
end

{:async, fun, state}
Expand Down

0 comments on commit 7958ff2

Please sign in to comment.