fix: Prevent whole-file PSI caching in highlight handler - #1659
Merged
angelozerr merged 2 commits intoSep 1, 2026
Conversation
angelozerr
reviewed
Aug 31, 2026
| // Returning null here would make the IDE cache the empty result for the whole plain-text file, | ||
| // and it would stop sending 'textDocument/documentHighlight' until the document changes. | ||
| // See https://github.com/redhat-developer/lsp4ij/issues/1300 | ||
| return isWholeFileElementAtCaret(editor, file) ? new LSPHighlightUsagesHandler(editor, file, targets) : null; |
Contributor
There was a problem hiding this comment.
It means that you will call findElementAt every time when targets are empty.
I think this issue is only for TEXT and textmate language. Generally PsiFile findElementAt doesnt return the full text range file.
So my suggestion is to replace isWholeFileElementAtCaret call with SimpleLanguageUtils.isSUpported(file.getLanguage())
Contributor
Author
There was a problem hiding this comment.
Thanks for the feedback. I wasn't aware of the SimpleLanguageUtils.isSupported() method. I retested with this change and it works perfectly.
Contributor
|
Thanks @ethanhann ! |
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.
Relates to #1300
Plugin version: 0.21.0
I verified this fix on RustRover 2026.1.4.
When a language server returns an empty highlight list for a file whose only PSI element spans the whole file, such as plain text, the empty result is cached for the whole file. It stops sending
documentHighlightrequests until the file is reopened which breaks highlighting. This PR returns an empty handler instead of null in that case. The empty result is cached for the caret offset only which allows highlighting to keep working.