aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/refactoringchanges.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2024-01-29 12:42:09 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2024-01-30 09:17:38 +0000
commit02de46110e44933f715e469149dfbfb8a148d446 (patch)
treed17464679ecbfaa8c34b83ae95f7bc4d2efc0e7e /src/plugins/texteditor/refactoringchanges.cpp
parent43221e495332ee4accce0fb5bf5095c711d2b74a (diff)
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>
Diffstat (limited to 'src/plugins/texteditor/refactoringchanges.cpp')
-rw-r--r--src/plugins/texteditor/refactoringchanges.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/plugins/texteditor/refactoringchanges.cpp b/src/plugins/texteditor/refactoringchanges.cpp
index 6eeffa7542..ebd487cc37 100644
--- a/src/plugins/texteditor/refactoringchanges.cpp
+++ b/src/plugins/texteditor/refactoringchanges.cpp
@@ -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();