forked from qt-creator/qt-creator
TextEditor: Insert clang-format removal blocker at the end
... of an "empty" line. Otherwise previous leading whitespace will survive re-formatting. Also reset the formatting cursors when setting a new change set. Fixes: QTCREATORBUG-30244 Change-Id: I3fb8668b56c3823972d4acda8da9657fb0bbfe41 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -202,6 +202,7 @@ void RefactoringFile::setChangeSet(const ChangeSet &changeSet)
|
||||
return;
|
||||
|
||||
m_changes = changeSet;
|
||||
m_formattingCursors.clear();
|
||||
}
|
||||
|
||||
void RefactoringFile::setOpenEditor(bool activate, int pos)
|
||||
@@ -365,8 +366,11 @@ void RefactoringFile::doFormatting()
|
||||
QTextBlock b = firstBlock;
|
||||
while (true) {
|
||||
QTC_ASSERT(b.isValid(), break);
|
||||
if (b.text().simplified().isEmpty())
|
||||
QTextCursor(b).insertText(clangFormatLineRemovalBlocker);
|
||||
if (b.text().simplified().isEmpty()) {
|
||||
QTextCursor c(b);
|
||||
c.movePosition(QTextCursor::EndOfBlock);
|
||||
c.insertText(clangFormatLineRemovalBlocker);
|
||||
}
|
||||
if (b == lastBlock)
|
||||
break;
|
||||
b = b.next();
|
||||
|
||||
Reference in New Issue
Block a user