@@ -591,7 +591,10 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
591591 {" save" , true },
592592 }},
593593 {" documentFormattingProvider" , true },
594- {" documentRangeFormattingProvider" , true },
594+ {" documentRangeFormattingProvider" ,
595+ llvm::json::Object{
596+ {" rangesSupport" , true },
597+ }},
595598 {" documentOnTypeFormattingProvider" ,
596599 llvm::json::Object{
597600 {" firstTriggerCharacter" , " \n " },
@@ -952,9 +955,17 @@ void ClangdLSPServer::onDocumentOnTypeFormatting(
952955void ClangdLSPServer::onDocumentRangeFormatting (
953956 const DocumentRangeFormattingParams &Params,
954957 Callback<std::vector<TextEdit>> Reply) {
958+ onDocumentRangesFormatting (
959+ DocumentRangesFormattingParams{Params.textDocument , {Params.range }},
960+ std::move (Reply));
961+ }
962+
963+ void ClangdLSPServer::onDocumentRangesFormatting (
964+ const DocumentRangesFormattingParams &Params,
965+ Callback<std::vector<TextEdit>> Reply) {
955966 auto File = Params.textDocument .uri .file ();
956967 auto Code = Server->getDraft (File);
957- Server->formatFile (File, Params.range ,
968+ Server->formatFile (File, Params.ranges ,
958969 [Code = std::move (Code), Reply = std::move (Reply)](
959970 llvm::Expected<tooling::Replacements> Result) mutable {
960971 if (Result)
@@ -970,7 +981,7 @@ void ClangdLSPServer::onDocumentFormatting(
970981 auto File = Params.textDocument .uri .file ();
971982 auto Code = Server->getDraft (File);
972983 Server->formatFile (File,
973- /* Rng =*/ std:: nullopt ,
984+ /* Rngs =*/ {} ,
974985 [Code = std::move (Code), Reply = std::move (Reply)](
975986 llvm::Expected<tooling::Replacements> Result) mutable {
976987 if (Result)
@@ -1666,6 +1677,7 @@ void ClangdLSPServer::bindMethods(LSPBinder &Bind,
16661677 Bind.method (" shutdown" , this , &ClangdLSPServer::onShutdown);
16671678 Bind.method (" sync" , this , &ClangdLSPServer::onSync);
16681679 Bind.method (" textDocument/rangeFormatting" , this , &ClangdLSPServer::onDocumentRangeFormatting);
1680+ Bind.method (" textDocument/rangesFormatting" , this , &ClangdLSPServer::onDocumentRangesFormatting);
16691681 Bind.method (" textDocument/onTypeFormatting" , this , &ClangdLSPServer::onDocumentOnTypeFormatting);
16701682 Bind.method (" textDocument/formatting" , this , &ClangdLSPServer::onDocumentFormatting);
16711683 Bind.method (" textDocument/codeAction" , this , &ClangdLSPServer::onCodeAction);
0 commit comments