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
A restart of a file's highlighting can be lost, when it comes from a background thread while the daemon applies a pass that it cancels #2356
A restart of a file's highlighting that LSP4IJ asks for, as for a language server's workspace/semanticTokens/refresh, workspace/inlayHint/refresh or workspace/codeLens/refresh, can be lost. The file then keeps its old highlighting until the next edit.
Cause
LSPFileSupport calls DaemonCodeAnalyzer.getInstance(project).restart(file) in a non-blocking read action, so on a background thread. restart marks the file dirty and cancels the daemon's passes in progress. The daemon applies a pass on the EDT once it has checked that the pass isn't cancelled (PassExecutorService.applyInformationToEditorsLater). So a restart from another thread can come between the check and the apply.
The pass is then applied although it is cancelled. When it is the EmptyPass of a pass that had nothing to do, as the general highlighting pass of a file that was up to date, applying it marks that pass up to date again. That erases the dirty mark of the restart, so the next run of the daemon has nothing to highlight again.
Seen in
The macOS job of #2338 (run 46192524593), SemanticTokensRefreshTest.testAPendingAnswerKeepsTheColorsAndLetsAWriteActionRun, on IntelliJ IDEA 2024.2. The test's log, in UTC:
Time
Event
21:54:56.776
The daemon, by its timer, starts a run, in which the general highlighting pass (id 4) is an EmptyPass
21:54:56.794
The refresh's restart, from a background thread: Mark scope dirty: (0,8), Psi file restart: test.luax, then Cancel Psi file restart
21:54:56.794
EmptyPass; id=4 Applied; progress=315431603 X: applied although cancelled (X), while the other passes of the run are "canceled during apply"
21:54:57.243
The daemon's next run: the general highlighting pass is an EmptyPass again, so no semantic tokens request is sent
21:55:06.353
The test fails, after 10 s without the request
The code has been like this since 0ebc3a9 (2025-04-03).
Fix
Call restart on the EDT, where the daemon applies its passes: in the finishOnUiThread of the same non-blocking read action, which keeps its debounce and coalescing.
Activity
fix: a restart of a file's highlighting is no longer lost when the da…