Skip to content

Commit

Permalink
Protect against NPE on Semantic Highlighting.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Apr 14, 2021
1 parent a9656c1 commit b6b0b71
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ public void beforeDocumentChange(@NotNull DocumentEvent event) {
document.addDocumentListener(listener);
}
try {
return Pair.create(semanticTokens.get(Timeouts.getSemanticHighlightingTimeout(), TimeUnit.SECONDS), connection);
SemanticTokens tokens = semanticTokens.get(Timeouts.getSemanticHighlightingTimeout(), TimeUnit.SECONDS);
if (tokens == null) {
return null;
}
return Pair.create(tokens, connection);
} catch (ProcessCanceledException | CompletionException | CancellationException | InterruptedException ignored) {
// Cancelled (InterruptedException is thrown when completion.cancel(true) is called from another thread).
return null;
Expand All @@ -78,6 +82,9 @@ public void beforeDocumentChange(@NotNull DocumentEvent event) {
@Override
public void apply(@NotNull PsiFile
file, Pair<SemanticTokens, EditorLanguageServerConnection> pair, @NotNull AnnotationHolder holder) {
if (pair == null) {
return;
}
ILSPEditor editor = pair.second.getEditor();
if (editor == null) {
return;
Expand Down

0 comments on commit b6b0b71

Please sign in to comment.