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