Skip to content

Commit

Permalink
Fix selective formatting (#1127)
Browse files Browse the repository at this point in the history
  • Loading branch information
travkin79 committed Oct 1, 2024
1 parent 4c0e997 commit 20afadd
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ public CompletableFuture<Optional<VersionedEdits>> requestFormatting(IDocument d
// range formatting, falling back to a full format if unavailable
long modificationStamp = DocumentUtil.getDocumentModificationStamp(document);
return executor.computeFirst((w, ls) -> w.getServerCapabilitiesAsync().thenCompose(capabilities -> {
if (textSelection.getLength() == 0 && isDocumentRangeFormattingSupported(capabilities)
&& !(isDocumentFormattingSupported(capabilities))) {
if (textSelection.getLength() != 0 && isDocumentRangeFormattingSupported(capabilities)) {
return ls.getTextDocumentService().rangeFormatting(rangeParams)
.thenApply(edits -> new VersionedEdits(modificationStamp, edits, document));
} else {
} else if (isDocumentFormattingSupported(capabilities)) {
return ls.getTextDocumentService().formatting(params)
.thenApply(edits -> new VersionedEdits(modificationStamp, edits, document));
} else {
return null;
}
}));
}
Expand Down

0 comments on commit 20afadd

Please sign in to comment.