Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.redhat.devtools.lsp4ij.LSPIJUtils;
import com.redhat.devtools.lsp4ij.LanguageServersRegistry;
import com.redhat.devtools.lsp4ij.client.indexing.ProjectIndexingManager;
import com.redhat.devtools.lsp4ij.internal.SimpleLanguageUtils;
import org.eclipse.lsp4j.DocumentHighlight;
import org.eclipse.lsp4j.DocumentHighlightKind;
import org.eclipse.lsp4j.TextDocumentIdentifier;
Expand Down Expand Up @@ -58,7 +59,13 @@ public class LSPHighlightUsagesHandlerFactory implements HighlightUsagesHandlerF
return null;
}
List<LSPHighlightPsiElement> targets = getTargets(editor, file);
return targets.isEmpty() ? null : new LSPHighlightUsagesHandler(editor, file, targets);
if (targets.isEmpty()) {
// For a TEXT or textmate file, returning null here would make the IDE cache the empty result
// for the whole file, and it would stop sending 'textDocument/documentHighlight' until the document changes.
// See https://github.com/redhat-developer/lsp4ij/issues/1300
return SimpleLanguageUtils.isSupported(file.getLanguage()) ? new LSPHighlightUsagesHandler(editor, file, targets) : null;
}
return new LSPHighlightUsagesHandler(editor, file, targets);
}

private List<LSPHighlightPsiElement> getTargets(Editor editor, PsiFile psiFile) {
Expand Down
Loading