Repository navigation
fix: a restart of a file's highlighting is no longer lost when the daemon applies a pass that it cancels - #2357
Merged
lagergren merged 2 commits intoNov 30, 2026
Conversation
…emon applies a pass that it cancels LSPFileSupport restarted the daemon for a file in a non-blocking read action, so on a background thread. The daemon applies a pass on the EDT once it has checked that the pass isn't cancelled, so a restart could come in between: the pass it cancelled was applied anyway, and when it had nothing to do, its EmptyPass marked the file as highlighted again, which erased the restart's dirty mark. The file then kept its old highlighting, as the semantic tokens of a workspace/semanticTokens/refresh, until the next edit. The restart now runs on the EDT, in the finishOnUiThread of the same non-blocking read action, which keeps its debounce and coalescing. Fixes redhat-developer#2356
1 of 2 tasks
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2357 +/- ##
==========================================
+ Coverage 58.63% 58.85% +0.22%
==========================================
Files 849 849
Lines 36719 36727 +8
Branches 7609 7610 +1
==========================================
+ Hits 21530 21616 +86
+ Misses 12187 12099 -88
- Partials 3002 3012 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…is indexed waits for the end of indexing LSPFileSupport.restartDaemonCodeAnalyzerWithDebounce meant the restart to wait for smart mode, but called action.inSmartMode(project) without keeping its result: each method of NonBlockingReadAction returns a new action, so the restart ran during indexing too, as it did since 0.13.0. It now waits. The daemon runs only the dumb-aware passes during indexing, and restarts the highlighting of every file once indexing ends, so the restart during indexing was work for nothing. Fixes redhat-developer#2363
Collaborator
Author
|
@coderabbitai review |
Action performed
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2356, fixes #2363, for 0.30.3. Two
fix:commits, to be rebase-merged.The bug
A restart of a file's highlighting that LSP4IJ asks for, as for
workspace/semanticTokens/refresh,workspace/inlayHint/refreshorworkspace/codeLens/refresh, could be lost. The file then kept its old highlighting until the next edit.LSPFileSupportcalledDaemonCodeAnalyzer.restart(file)in a non-blocking read action, so on a background thread. The daemon applies a pass on the EDT once it has checked that the pass isn't cancelled, so the restart could come between the check and the apply. The pass it cancelled was then applied anyway. When it was theEmptyPassof a pass that had nothing to do, it marked the file as highlighted again, which erased the restart's dirty mark.It turned up in the macOS job of #2338, whose new
SemanticTokensRefreshTestwaits for a refresh while the daemon runs by its timer. #2356 has that test's log, in which theEmptyPassof the general highlighting pass is applied after the restart cancelled it.The fix
restartnow runs on the EDT, in thefinishOnUiThreadof the same non-blocking read action, which keeps its debounce and coalescing. It doesn't restart a file that is no longer valid by then.A
@TestOnlyhook,setRestartHook, runs right after the restart, assetRestartDebouncelets a test set the debounce.The second fix (#2363)
action.inSmartMode(project)discarded the copy that it returns, as each method ofNonBlockingReadActionreturns a new action, so a restart that came while the project was indexed ran at once, since 0.13.0. It now waits for the end of indexing, as the code meant:action = action.inSmartMode(project). Little changes for the user: during indexing, the daemon runs only the dumb-aware passes, and it restarts the highlighting of every file once indexing ends. A@TestOnlygetter,getLastRestart, gives a test the restart that the debounce submitted.Checked
LSPFileSupportRestartThreadTestchecks that the restart runs on the EDT. With the restart in the background read action, as before, it fails with "The highlighting must restart on the EDT".LSPFileSupportRestartWhileIndexingTestrequests a restart in dumb mode. Once a non-blocking action submitted after it has run, the restart must still be pending, and it must run once indexing ends, in smart mode. Without the fix, it failed 3 times out of 3 with "The restart must wait for the end of indexing". With it, it passes on IC 2024.2, IC 2025.3 and IU 2026.3, withLSPFileSupportRestartThreadTest.LSPFileSupportRestartThreadTest,CodeActionsOnTheEdtTest