Skip to content

lsp: documentSymbol selectionRange is zero-width, breaks VS Code Outline #366

@jimisola

Description

@jimisola

Summary

The LSP server's textDocument/documentSymbol response returns a fully populated symbol tree for requirements.yml, but VS Code's built-in Outline view shows nothing. The cause is that every symbol's selectionRange is zero-width (start == end) at column 0, which VS Code silently rejects/drops because selectionRange is supposed to span the symbol's clickable name.

Reproduce

  1. Open a project containing a requirements.yml in VS Code with the reqstool extension active.
  2. Open the YAML file and the Outline view (Explorer sidebar).
  3. Outline is empty.
  4. With reqstool.trace.server set to verbose, the server's response to textDocument/documentSymbol is a complete tree — proving the request reaches the server and the server has the data.

Example response (excerpt)

{
  "name": "WEB_0001 — Web UI Launch",
  "kind": 20,
  "range":          {"start": {"line": 16, "character": 0}, "end": {"line": 24, "character": 0}},
  "selectionRange": {"start": {"line": 16, "character": 0}, "end": {"line": 16, "character": 0}},
  "detail": "shall",
  "children": [ ... ]
}

selectionRange start equals end — a zero-width point at column 0.

Expected

Per LSP / VS Code, selectionRange should span the identifier text — e.g. cover id: WEB_0001 (or just WEB_0001) on the line where the requirement is declared. With a non-empty selectionRange contained in range, VS Code populates the Outline normally.

Suggested fix

When building DocumentSymbols in src/reqstool/lsp/features/ (the documentSymbol provider), set selectionRange to the actual span of the requirement's id: value in the YAML source rather than (line, 0)–(line, 0).

Environment

  • reqstool-vscode 0.1.0 (latest main)
  • VS Code with reqstool.trace.server: verbose
  • Server: reqstool lsp (pygls)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions