forked from qt-creator/qt-creator
Utils: Add formatting information to ChangeSet::EditOp
... and make use of that in TextEditor::RefactoringFile. This allows calling code to have fine-grained control over which parts of a refactoring should get re-formatted, while also providing sensible default values that are "almost always" right, so things typically work as expected out of the box. Change-Id: I9200c2135b7477c33bc5a61c5d410b34853e4b61 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -436,15 +436,15 @@ int indentationForBlock(const Utils::ChangeSet &toReplace,
|
||||
|
||||
auto replacementIt
|
||||
= std::find_if(ops.begin(), ops.end(), [utf8Offset](const Utils::ChangeSet::EditOp &op) {
|
||||
QTC_ASSERT(op.type == Utils::ChangeSet::EditOp::Replace, return false);
|
||||
QTC_ASSERT(op.type() == Utils::ChangeSet::EditOp::Replace, return false);
|
||||
return op.pos1 == utf8Offset - 1;
|
||||
});
|
||||
if (replacementIt == ops.end())
|
||||
return -1;
|
||||
|
||||
int afterLineBreak = replacementIt->text.lastIndexOf('\n');
|
||||
int afterLineBreak = replacementIt->text().lastIndexOf('\n');
|
||||
afterLineBreak = (afterLineBreak < 0) ? 0 : afterLineBreak + 1;
|
||||
return static_cast<int>(replacementIt->text.size() - afterLineBreak);
|
||||
return static_cast<int>(replacementIt->text().size() - afterLineBreak);
|
||||
}
|
||||
|
||||
bool doNotIndentInContext(QTextDocument *doc, int pos)
|
||||
|
||||
Reference in New Issue
Block a user