aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2009-11-09 18:53:59 +0100
committercon <qtc-committer@nokia.com>2009-11-10 13:59:51 +0100
commitb37312b5ab7e6b4c342dbee1b73d26efeb4e4701 (patch)
tree98b0cd87bd84c5663fe62741b28ac7c5d3617c1f
parentc61e893a08c41c9c0f90f6e3a0c8eca1257ff23d (diff)
Fix pasting of text that starts with a visually empty line
Creator only indents the first line, and reindents subsequent lines relative to the indentation change of said first line. This fails when the first line contains no non-space characters. Solution in this change: skip (visually) empty lines. Reviewed-by: thorbjorn Task-number: QTCREATORBUG-227 (cherry picked from commit 4ef2caca3afcfe5fc9231556b73a6d8aa61469e8)
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 982ce7de3f3..278ea7f0f20 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -3415,6 +3415,16 @@ void BaseTextEditor::reindent(QTextDocument *doc, const QTextCursor &cursor)
const QTextBlock end = doc->findBlock(cursor.selectionEnd()).next();
const TabSettings &ts = d->m_document->tabSettings();
+
+ // skip empty blocks
+ while (block.isValid() && block != end) {
+ QString bt = block.text();
+ if (ts.firstNonSpace(bt) < bt.size())
+ break;
+ indentBlock(doc, block, QChar::Null);
+ block = block.next();
+ }
+
int previousIndentation = ts.indentationColumn(block.text());
indentBlock(doc, block, QChar::Null);
int currentIndentation = ts.indentationColumn(block.text());