Added workaround for indentation not working when inserting text at the beginning of a range.

This commit is contained in:
Roberto Raggi
2010-06-22 15:09:20 +02:00
parent 23aa0af883
commit c3657634ed

View File

@@ -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));
}