Skip to content

Commit e7f5d17

Browse files
authored
Fix formatting bug with multiple changes. (#11599)
1 parent 16f6cf9 commit e7f5d17

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Extension/src/LanguageServer/client.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3610,7 +3610,8 @@ export class DefaultClient implements Client {
36103610
const settings: OtherSettings = new OtherSettings(vscode.workspace.getWorkspaceFolder(formatUriAndRange.uri)?.uri);
36113611
const formatOptions: vscode.FormattingOptions = {
36123612
insertSpaces: settings.editorInsertSpaces ?? true,
3613-
tabSize: settings.editorTabSize ?? 4
3613+
tabSize: settings.editorTabSize ?? 4,
3614+
onChanges: true
36143615
};
36153616

36163617
const doFormat = async () => {
@@ -3619,10 +3620,8 @@ export class DefaultClient implements Client {
36193620
return true;
36203621
}
36213622

3622-
// TODO: Somehow invoke multiple range formatting (see https://github.com/microsoft/vscode/issues/193836).
3623-
// Maybe call DocumentRangeFormattingEditProvider.provideDocumentRangesFormattingEdits directly.
36243623
const formatTextEdits: vscode.TextEdit[] | undefined = await vscode.commands.executeCommand<vscode.TextEdit[] | undefined>(
3625-
"vscode.executeFormatRangeProvider", formatUriAndRange.uri, formatUriAndRange.range, formatOptions);
3624+
"vscode.executeFormatDocumentProvider", formatUriAndRange.uri, formatOptions);
36263625
if (!formatTextEdits || formatTextEdits.length === 0 || versionBeforeFormatting === undefined) {
36273626
return true;
36283627
}

0 commit comments

Comments
 (0)