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
This commit is contained in:
mae
2009-11-09 18:53:59 +01:00
parent f257f19b03
commit 4ef2caca3a

View File

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