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;
|
return;
|
||||||
|
|
||||||
m_changes = changeSet;
|
m_changes = changeSet;
|
||||||
|
m_formattingCursors.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefactoringFile::setOpenEditor(bool activate, int pos)
|
void RefactoringFile::setOpenEditor(bool activate, int pos)
|
||||||
@@ -365,8 +366,11 @@ void RefactoringFile::doFormatting()
|
|||||||
QTextBlock b = firstBlock;
|
QTextBlock b = firstBlock;
|
||||||
while (true) {
|
while (true) {
|
||||||
QTC_ASSERT(b.isValid(), break);
|
QTC_ASSERT(b.isValid(), break);
|
||||||
if (b.text().simplified().isEmpty())
|
if (b.text().simplified().isEmpty()) {
|
||||||
QTextCursor(b).insertText(clangFormatLineRemovalBlocker);
|
QTextCursor c(b);
|
||||||
|
c.movePosition(QTextCursor::EndOfBlock);
|
||||||
|
c.insertText(clangFormatLineRemovalBlocker);
|
||||||
|
}
|
||||||
if (b == lastBlock)
|
if (b == lastBlock)
|
||||||
break;
|
break;
|
||||||
b = b.next();
|
b = b.next();
|
||||||
|
|||||||
Reference in New Issue
Block a user