From c3657634ed856973ea19dfda3c88ae089015bc16 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Tue, 22 Jun 2010 15:09:20 +0200 Subject: [PATCH] Added workaround for indentation not working when inserting text at the beginning of a range. --- src/plugins/texteditor/refactoringchanges.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/texteditor/refactoringchanges.cpp b/src/plugins/texteditor/refactoringchanges.cpp index 45eec47a32d..2bee7d79b0f 100644 --- a/src/plugins/texteditor/refactoringchanges.cpp +++ b/src/plugins/texteditor/refactoringchanges.cpp @@ -35,6 +35,7 @@ #include #include #include +#include using namespace TextEditor; @@ -97,7 +98,8 @@ QStringList RefactoringChanges::apply() foreach (const Range &range, m_indentRangesByFile.value(fileName, QList())) { 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)); }