diff --git a/src/plugins/texteditor/syntaxhighlighter.cpp b/src/plugins/texteditor/syntaxhighlighter.cpp
index 8c81bda480524b63de4be03491dd887c019bc67c..f39e8c6d2fc28487c1da325ddc50bc2c0705563b 100644
--- a/src/plugins/texteditor/syntaxhighlighter.cpp
+++ b/src/plugins/texteditor/syntaxhighlighter.cpp
@@ -695,15 +695,18 @@ static bool byStartOfRange(const QTextLayout::FormatRange &range, const QTextLay
 void SyntaxHighlighter::setExtraAdditionalFormats(const QTextBlock& block,
                                                   const QList<QTextLayout::FormatRange> &fmts)
 {
-
 //    qDebug() << "setAdditionalFormats() on block" << block.blockNumber();
+//    qDebug() << "   is valid:" << (block.isValid() ? "Yes" : "No");
+//    qDebug() << "   has layout:" << (block.layout() ? "Yes" : "No");
+//    if (block.layout()) qDebug() << "   has text:" << (block.text().isEmpty() ? "No" : "Yes");
+
 //    for (int i = 0; i < overrides.count(); ++i)
 //        qDebug() << "   from " << overrides.at(i).start << "length"
 //                 << overrides.at(i).length
 //                 << "color:" << overrides.at(i).format.foreground().color();
     Q_D(SyntaxHighlighter);
 
-    if (block.layout() == 0)
+    if (block.layout() == 0 || block.text().isEmpty())
         return;
 
     QList<QTextLayout::FormatRange> formats;