Skip to content

Add support for TextDocument version on diagnostics push notifications #983

@benjamincburns

Description

@benjamincburns

Problem

There's no reliable mechanism by which a generic LSP client can determine if it has the most recent diagnostics for a given TextDocument version because there's no direct association between TextDocument state and diagnostic state.

Requested change

typescript-language-server should support the version field of textDocument/publishDiagnostics that was introduced in the LSP spec version 3.15 (see diagnostics section in LSP spec v3.17 for details).

Why it matters

I'm attempting to use LSP for AI coding agents, and diagnostics are important feedback. When providing feedback to an AI Agent, it's important to provide that feedback in the context of the action the triggered the feedback. If diagnostics feedback is delayed or out of date, it confuses the agent, and this often sends it into a tailspin as it tries to diagnose and troubleshoot issues that are no longer relevant.

Other solutions

Pull diagnostics (as requested in #972) is arguably a better solution to this problem, especially since it handles grouping diagnostics (e.g. if an edit to one file breaks other files) from multiple files into a single diagnostics report, though I expect that this is probably a heavier lift than supporting the version field on push diagnostics.

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