You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Range must be inside element being annotated: a diagnostic falls outside the file right after a completion #2030
LSPDiagnosticsApplier collects the diagnostics of a file in a non-blocking read action that doesn't wait for the file's document to be committed. LSPDiagnosticFeature.createAnnotation places a diagnostic at offsets of the document, but annotates the Psi file. Right after a completion inserts text, the document is longer than the Psi file until it is committed, so a diagnostic of the inserted text falls outside the Psi file and IntelliJ throws:
com.intellij.diagnostic.PluginException: Range must be inside element being annotated: (0,735); but got: (766,772)
at com.intellij.codeInsight.daemon.impl.B.range(B.java:200)
at com.redhat.devtools.lsp4ij.client.features.LSPDiagnosticFeature.createAnnotation(LSPDiagnosticFeature.java:110)
at com.redhat.devtools.lsp4ij.features.diagnostics.LSPDiagnosticsCollector.collect(LSPDiagnosticsCollector.java:122)
at com.redhat.devtools.lsp4ij.features.diagnostics.LSPDiagnosticsApplier.collectDiagnostics(LSPDiagnosticsApplier.java:241)
at com.redhat.devtools.lsp4ij.features.diagnostics.LSPDiagnosticsApplier.lambda$scheduleRefresh$2(LSPDiagnosticsApplier.java:115)
at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$OTelMonitor.callWrapped(NonBlockingReadActionImpl.java:1055)
The IDE reports Last Action: EditorChooseLookupItem. The refresh fails, so the file's new diagnostics aren't shown until the next update. LSPDiagnosticsCollector catches an IndexOutOfBoundsException from a stale range, but not this.
Seen in a language plugin's UI tests on IntelliJ IDEA 2026.2.3 with LSP4IJ 0.30.1: 3 of 8 runs once the test IDE no longer synchronized files on frame activation, which in those tests happened often enough to commit the document first.
Activity
fix: collect the diagnostics of a file only once its document is comm…