diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index b551447aef..c22e7b10ef 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -3608,6 +3608,15 @@ export class DefaultClient implements Client { return; } + if (headerFormatUriAndRanges.length > 0) { + // The header needs to be open and shown or the formatting will fail + // (due to issues/requirements in the cpptools process). + // It also seems strange and undesirable to have the header modified + // without being opened because otherwise users may not realize that + // the header had changed (unless they view source control differences). + await vscode.window.showTextDocument(headerFormatUriAndRanges[0].uri, { preserveFocus: true }); + } + // Apply the extract to function text edits. await vscode.workspace.applyEdit(workspaceEdits, { isRefactoring: true });