CppEditor: Enable formatting for "apply signature changes" action

So that the changes done by our internal rewriter get properly formatted
afterwards by ClangFormat (if enabled).

Fixes: QTCREATORBUG-31104
Change-Id: I4066ef56a765a8f2c2542b4f9220f1857d013624
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2024-10-28 16:34:28 +01:00
parent 768494b611
commit 05ae8f2fa8
2 changed files with 7 additions and 1 deletions

View File

@@ -271,7 +271,12 @@ void FunctionDeclDefLink::apply(CppEditorWidget *editor, bool jumpToMatch)
const int jumpTarget = newTargetFile->position(targetFunction->line(), targetFunction->column());
newTargetFile->setOpenEditor(true, jumpTarget);
}
newTargetFile->apply(changes(snapshot, targetStart));
ChangeSet changeSet = changes(snapshot, targetStart);
for (ChangeSet::EditOp &op : changeSet.operationList()) {
if (op.type() == ChangeSet::EditOp::Replace)
op.setFormat1(true);
}
newTargetFile->apply(changeSet);
} else {
ToolTip::show(editor->toolTipPosition(linkSelection),
Tr::tr("Target file was changed, could not apply changes"));

View File

@@ -357,6 +357,7 @@ void RefactoringFile::doFormatting()
indenterOwner.reset(factory ? factory->createIndenter(document)
: new PlainTextIndenter(document));
indenter = indenterOwner.get();
indenter->setFileName(filePath());
tabSettings = TabSettings::settingsForFile(filePath());
}
QTC_ASSERT(document, return);