summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2009-11-09 18:53:59 +0100
committermae <qt-info@nokia.com>2009-11-09 18:58:31 +0100
commit4ef2caca3afcfe5fc9231556b73a6d8aa61469e8 (patch)
tree13735fb6460d42fcc558e4a82a21235f7a19cf56
parentf257f19b03e009c239bbcd0463744cb28b21504d (diff)
downloadqt-creator-4ef2caca3afcfe5fc9231556b73a6d8aa61469e8.tar.gz
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
-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 982ce7de3f..278ea7f0f2 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());