Repository navigation
Description
Summary
Since fa5764c, textDocument/publishDiagnostics is rendered reactively by
LSPDiagnosticsApplier.scheduleRefresh, which captures the document's modification
stamp, collects highlights off-thread, and on the UI thread SKIPS the apply when the
stamp has moved in between (applyHighlights: if (data.document.getModificationStamp() != data.modificationStamp) return;). Nothing reschedules after that skip.
OpenedDocument.updateDiagnostics only calls scheduleRefresh when
LSPDiagnosticsForServer.update(...) reports the set CHANGED
(LSPDiagnosticUtils.isDiagnosticsChanged), and DocumentContentSynchronizer never
re-applies on documentChanged.
Combined: one publish that lands while the document is still being edited is dropped,
and every following publish carrying the SAME set is treated as "unchanged" and never
re-applied. The editor keeps showing the LAST successfully applied set — which can be
an error from several edits ago — until the server's answer differs again.
Reproduction
Any server that re-validates on every didChange and offers InsertTextFormat.Snippet
completions will do. Take a configuration-style language where a property is written
as name value and a value can be a block:
- Type a property name with no value yet, e.g.
server— the server reports
"expected a value after property name 'server'" at the end of the line. LSP4IJ
applies it; the squiggle shows. - Accept a snippet completion that inserts a multi-line block with two tab stops, e.g.
{\n host "$1"\n port $2\n}. LSP4IJ applies the edit and starts the inline
template; the insertion plus per-line re-indent are several document changes in a
row. - The server publishes a new error for the half-filled block ("expected a value for
'port'").scheduleRefreshruns while the template is still churning the document
→ modification-stamp mismatch → apply dropped. The step-1 squiggle stays. - Type into
$1. Every keystroke republishes the identical "expected a value for
'port'" →isDiagnosticsChangedis false → no refresh. The screen still shows the
step-1 error, on a line that is now valid. - Fill
$2so the document is clean. The[]publish can be dropped the same way
(the template's own edits on finishing land in the window); afterwards every[]
is "unchanged". The step-1 error is now permanent. - Type an unrelated broken line elsewhere: a NEW diagnostic arrives → "changed" →
refresh applies → the stale one finally disappears.
With the server's LSP trace at verbose, textDocument/didChange and
textDocument/publishDiagnostics both flow correctly throughout; the server's last
payload is [] while the editor keeps showing the step-1 error. A single-line snippet
with one tab stop rarely triggers it — fewer document changes in the window — which is
why it looks like a property of "bigger" completions.
Expected
A publish that could not be applied must not be lost. The stored diagnostics
(LSPDiagnosticsForServer) are already the newest; only the RENDER is stale.
Suggested fix (either is enough)
- In
LSPDiagnosticsApplier.applyHighlights, on a modification-stamp mismatch,
re-runscheduleRefresh(file, psiFile, document)instead of returning (the collector
re-maps ranges against the current document; thecoalesceByalready dedups, and each
retry captures the current stamp, so it settles as soon as the document does). - Or track "last apply dropped" per document and have
OpenedDocument.updateDiagnostics
callscheduleRefreshwhen that flag is set even ifupdate(...)returned false.
Pre-fa5764c the external annotator re-ran with the daemon on every document change, so
a missed frame healed on the next keystroke; the reactive path has no such retry.
Activity
Fix: Reschedule diagnostics refresh on modification-stamp mismatch
fix: Reschedule diagnostics refresh on modification-stamp mismatch
angelozerr commentedon Sep 14, 2026
@bamboo I created the PR #1666
Could you please try it by foolowing instruction at https://github.com/redhat-developer/lsp4ij#testing-the-ci-builds and give me feedback.
Thanks!
bamboo commentedon Sep 14, 2026
That's great, @angelozerr. I just tried it and I can confirm the fix works.
Thanks for the quick fix!
angelozerr commentedon Sep 14, 2026
Thanks @bamboo for your review!
I have started a nighty build https://github.com/redhat-developer/lsp4ij/actions/runs/34849726147 which will be available soon.
And if you like LSP4IJ please add a review in JetBrains marketplace to help us to promote LSP4IJ. Thanks!
fix: Reschedule diagnostics refresh on modification-stamp mismatch