Skip to content

feat(lsp): cache diagnostics across editor restarts - #296

Merged
fcoury-oai merged 1 commit into
mainfrom
fcoury/lsp-diagnostics-cache
Aug 21, 2026
Merged

feat(lsp): cache diagnostics across editor restarts#296
fcoury-oai merged 1 commit into
mainfrom
fcoury/lsp-diagnostics-cache

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Why

Restarting Red clears all LSP findings until language servers initialize and republish them. Larger workspaces can therefore reopen without gutter markers or diagnostics even when their source files and project configuration have not changed.

What Changed

  • Persist push and pull diagnostics in owner-private, workspace-scoped caches with debounced background writes and 24-hour expiration.
  • Restore matching findings before the first render, including unsaved recovered buffers, unopened workspace files, and workspaces opened after startup.
  • Reuse cached findings only when document SHA-256, language-server configuration, workspace identity, and relevant manifests or lockfiles still match.
  • Treat restored findings as provisional, refresh after server initialization, and replace both cached channels when the first authoritative report arrives.

How to Test

  1. Open a Rust workspace containing a compiler error and confirm its diagnostic appears in the gutter or diagnostics picker.

  2. Close and reopen Red in the same workspace. The previous finding should appear immediately, then refresh once rust-analyzer initializes.

  3. Change the source file, Cargo.toml, Cargo.lock, or rust-analyzer configuration while Red is closed. Reopen the workspace and confirm stale findings are not restored.

  4. Recover an unsaved session with red --resume and confirm restored findings match the recovered in-memory text rather than older on-disk contents.

  5. Run the focused regressions:

    cargo test -p red --lib editor::diagnostics::tests::
    cargo test -p red --test lsp_lazy

    Coverage includes matching and changed content, dirty buffers, server and manifest invalidation, unopened files, lazy hydration, workspace isolation, expiration, cleared findings, and push/pull replacement.

Validated with 2,084 passing library tests, 48 passing lazy-LSP integration tests, and clean all-target/all-feature Clippy and formatting checks.

@fcoury-oai
fcoury-oai merged commit e06bf54 into main Aug 21, 2026
10 checks passed
@fcoury-oai
fcoury-oai deleted the fcoury/lsp-diagnostics-cache branch August 21, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant