Change:
<!-- Do Not Delete This! featurerequesttemplate --<!-- Please read our Rules of Conduct: --<!-- Please search existing issues to avoid creating duplicates. --<!-- Describe the feature you'd like. --With set to , VSCode will sequentially send requests to its provider(s). It'd be nice if the whole list of ranges could be sent at once instead of sequentially, allowing the formatter to handle this batch as it sees fit. This could be achieved by modifying to take an additional optional metadata parameter that the provider can use to express support for this mode.
<!-- -96bd-47a8-a0e8- --This feature request is now a candidate for our backlog. The community has 60 days to the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our . Happy Coding!
Would the team be open to PR for this change? I'm happy to provide one.
To give additional context, we've had user reports like this: When a file has lots of modified chunks, we see lots of round-trips to the server. Batching the requests can provide a very important performance improvement in some cases.
<!-- -a7ce-58b9-b1f9- --This feature request has not yet received the 20 community it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our . Happy Coding!
feedback from API sync, have explicit optional function
fyi this is done and LSP adoption is welcome
already provided a PR for LSP.
To verify: make sure API has a new optional function and make sure it's properly documented (extra) write a dummy extension that implements this and make sure it's called

Discussion:
registerDocumentRangeFormattingEditProvider(extension: IExtensionDescription, selector: vscode.DocumentSelector, provider: vscode.DocumentRangeFormattingEditProvider): vscode.Disposable { const canFormatMultipleRanges = typeof provider.provideDocumentRangesFormattingEdits === 'function'; <del> if (canFormatMultipleRanges) { checkProposedApiEnabled(extension, 'formatMultipleRanges'); } </del> const handle = this._addNewAdapter(new RangeFormattingAdapter(this._documents, provider), extension); this._proxy.$registerRangeFormattingSupport(handle, this._transformDocumentSelector(selector, extension), extension.identifier, extension.displayName || extension.name, canFormatMultipleRanges); return this._createDisposable(handle);

fileComments: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.fileComments.d.ts', fileSearchProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.fileSearchProvider.d.ts', findTextInFiles: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.findTextInFiles.d.ts', <del> formatMultipleRanges: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.formatMultipleRanges.d.ts', </del> fsChunks: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.fsChunks.d.ts', handleIssueUri: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.handleIssueUri.d.ts', idToken: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.idToken.d.ts',

* signaled by returning `undefined`, `null`, or an empty array. */ provideDocumentRangeFormattingEdits(document: TextDocument, range: Range, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>; <ins> /** * Provide formatting edits for multiple ranges in a document. * * This function is optional but allows a formatter to perform faster when formatting only modified ranges or when * formatting a large number of selections. * * The given ranges are hints and providers can decide to format a smaller * or larger range. Often this is done by adjusting the start and end * of the range to full syntax nodes. * * @param document The document in which the command was invoked. * @param ranges The ranges which should be formatted. * @param options Options controlling formatting. * @param token A cancellation token. * @return A set of text edits or a thenable that resolves to such. The lack of a result can be * signaled by returning `undefined`, `null`, or an empty array. */ provideDocumentRangesFormattingEdits?(document: TextDocument, ranges: Range[], options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>; </ins> } /**

<del> /*--------------------------------------------------------------------------------------------- *  Copyright (c) Microsoft Corporation. All rights reserved. *  Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ declare module 'vscode' { // https://github.com/microsoft/vscode/issues/158776 export interface DocumentRangeFormattingEditProvider { /** * Provide formatting edits for multiple ranges in a document. * * The given ranges are hints and providers can decide to format a smaller * or larger range. Often this is done by adjusting the start and end * of the range to full syntax nodes. * * @param document The document in which the command was invoked. * @param ranges The ranges which should be formatted. * @param options Options controlling formatting. * @param token A cancellation token. * @return A set of text edits or a thenable that resolves to such. The lack of a result can be * signaled by returning `undefined`, `null`, or an empty array. */ provideDocumentRangesFormattingEdits?(document: TextDocument, ranges: Range[], options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>; } } </del>