diff --git a/src/plugins/cppeditor/cpphighlighter.cpp b/src/plugins/cppeditor/cpphighlighter.cpp index 95e25b4b2573db244b2d9b9ff21975939026ac7c..d2cda6f77df79a7287db641d0b8fed866b0b5aac 100644 --- a/src/plugins/cppeditor/cpphighlighter.cpp +++ b/src/plugins/cppeditor/cpphighlighter.cpp @@ -73,6 +73,8 @@ void CppHighlighter::highlightBlock(const QString &text) userData->setCollapseMode(TextBlockUserData::NoCollapse); } TextEditDocumentLayout::clearParentheses(currentBlock()); + if (text.length()) // the empty line can still contain whitespace + setFormat(0, text.length(), visualSpaceFormat); return; } @@ -171,7 +173,7 @@ void CppHighlighter::highlightBlock(const QString &text) } // mark the trailing white spaces - if (! tokens.isEmpty()) { + { const SimpleToken tk = tokens.last(); const int lastTokenEnd = tk.position() + tk.length(); if (text.length() > lastTokenEnd)