Skip to content

Commit b7c09e6

Browse files
committed
Fix format without selected range when documentFormattingProvider=false
In case documentRangeFormattingProvider=true && documentFormattingProvider==false, the conditions were leading to no request being sent. This commit reworks condition so that one may be used as a failback for the other when only one capability is set. Fixes eclipse-wildwebdeveloper/wildwebdeveloper#1835
1 parent 14743b5 commit b7c09e6

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/format/LSPFormatter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public CompletableFuture<Optional<VersionedEdits>> requestFormatting(IDocument d
5656
// range formatting, falling back to a full format if unavailable
5757
long modificationStamp = DocumentUtil.getDocumentModificationStamp(document);
5858
return executor.computeFirst((w, ls) -> w.getServerCapabilitiesAsync().thenCompose(capabilities -> {
59-
if (textSelection.getLength() != 0 && isDocumentRangeFormattingSupported(capabilities)) {
59+
if (isDocumentRangeFormattingSupported(capabilities) && (textSelection.getLength() > 0 || !isDocumentFormattingSupported(capabilities))) {
6060
return ls.getTextDocumentService().rangeFormatting(rangeParams)
6161
.thenApply(edits -> new VersionedEdits(modificationStamp, edits, document));
6262
} else if (isDocumentFormattingSupported(capabilities)) {

0 commit comments

Comments
 (0)