VCS: Do not wrap lines that start with tab in submit editor

This breaks "Conflicts" section in Git, and possibly others

Change-Id: I821fd147194af0ce3902cedad02f373d6892e665
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Orgad Shaneh
2014-01-28 22:37:46 +02:00
committed by Orgad Shaneh
parent aa6dd83e08
commit 7f21e8b29f

View File

@@ -34,6 +34,7 @@
#include <QDebug> #include <QDebug>
#include <QPointer> #include <QPointer>
#include <QTextBlock>
#include <QTimer> #include <QTimer>
#include <QScopedPointer> #include <QScopedPointer>
@@ -299,12 +300,22 @@ static QString wrappedText(const QTextEdit *e)
QTextCursor cursor(e->document()); QTextCursor cursor(e->document());
cursor.movePosition(QTextCursor::Start); cursor.movePosition(QTextCursor::Start);
while (!cursor.atEnd()) { while (!cursor.atEnd()) {
const QString block = cursor.block().text();
if (block.startsWith(QLatin1Char('\t'))) { // Don't wrap
rc += block + newLine;
} else {
forever {
cursor.select(QTextCursor::LineUnderCursor); cursor.select(QTextCursor::LineUnderCursor);
rc += cursor.selectedText(); rc += cursor.selectedText();
rc += newLine; rc += newLine;
cursor.movePosition(QTextCursor::EndOfLine); // Mac needs it cursor.movePosition(QTextCursor::EndOfLine); // Mac needs it
if (cursor.atBlockEnd())
break;
cursor.movePosition(QTextCursor::NextCharacter); cursor.movePosition(QTextCursor::NextCharacter);
} }
}
cursor.movePosition(QTextCursor::NextBlock);
}
return rc; return rc;
} }