Skip to content

LSP definition and references conflate common tokens across the workspace #2831

Description

@Widthdom

Summary

textDocument/definition and textDocument/references extract only the token at the cursor and then run global exact symbol/reference queries. Common names such as Run, Build, Handle, or Dispose can therefore return unrelated definitions or references from other files and types.

Evidence

  • src/CodeIndex/Lsp/LspServer.cs:103 calls ExtractPositionToken and then _reader.GetDefinitions(query, DefaultLimit, exact: true).
  • src/CodeIndex/Lsp/LspServer.cs:116 calls _reader.AnalyzeSymbol(query, DefaultLimit, exact: true).
  • src/CodeIndex/Lsp/LspServer.cs:143 resolves the document path only to read the token; the path/container is not carried into the query.

Expected

LSP definition and references should use file, line, and enclosing symbol context when available, or at minimum narrow results to the current indexed file or plausible container before falling back to global exact-name lookup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions