GH-1380: return null instead of empty list when there are no document hightlights found to avoid confusion on the client side

This commit is contained in:
Martin Lippert
2024-10-09 12:47:30 +02:00
parent 9b1052bf0a
commit 16f4d0c014

View File

@@ -654,12 +654,13 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE
DocumentHighlightHandler handler = this.documentHighlightHandler;
if (handler != null) {
return CompletableFutures.computeAsync(messageWorkerThreadPool, cancelToken -> {
return handler.handle(cancelToken, highlightParams);
List<? extends DocumentHighlight> result = handler.handle(cancelToken, highlightParams);
return result != null && result.size() > 0 ? result : null;
});
}
else {
return CompletableFuture.completedFuture(Collections.emptyList());
return CompletableFuture.completedFuture(null);
}
}