forked from qt-creator/qt-creator
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:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user