From 4ef2caca3afcfe5fc9231556b73a6d8aa61469e8 Mon Sep 17 00:00:00 2001 From: mae Date: Mon, 9 Nov 2009 18:53:59 +0100 Subject: [PATCH] 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 --- src/plugins/texteditor/basetexteditor.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) 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());