diff --git a/src/plugins/texteditor/refactoringchanges.cpp b/src/plugins/texteditor/refactoringchanges.cpp index 45eec47a32df4e53654a07427ac7d6f880e95e21..2bee7d79b0fee8318265754a1a3fcdbeb4105432 100644 --- a/src/plugins/texteditor/refactoringchanges.cpp +++ b/src/plugins/texteditor/refactoringchanges.cpp @@ -35,6 +35,7 @@ #include <QtCore/QFile> #include <QtCore/QSet> #include <QtGui/QTextBlock> +#include <QtCore/QDebug> using namespace TextEditor; @@ -97,7 +98,8 @@ QStringList RefactoringChanges::apply() foreach (const Range &range, m_indentRangesByFile.value(fileName, QList<Range>())) { QTextCursor start = editor->textCursor(); QTextCursor end = editor->textCursor(); - start.setPosition(range.start); + // ### workaround for moving the textcursor when inserting text at the beginning of the range. + start.setPosition(qMax(0, range.start - 1)); end.setPosition(range.end); cursorPairs.append(qMakePair(start, end)); }