Commit 55302393 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Don't highlight \ at end of line as whitespace

It is not considered a token by the C++ tokenizer, and was hence
considered to be trailing whitespace. Use the highightLine method to
make sure that any non-whitespace characters in this "trailing
whitespace" are not highlighted as such.

Task-number: QTCREATORBUG-987
parent b5b29532
......@@ -174,7 +174,7 @@ void CppHighlighter::highlightBlock(const QString &text)
const SimpleToken tk = tokens.last();
const int lastTokenEnd = tk.position() + tk.length();
if (text.length() > lastTokenEnd)
setFormat(lastTokenEnd, text.length() - lastTokenEnd, m_formats[CppVisualWhitespace]);
highightLine(text, lastTokenEnd, text.length() - lastTokenEnd, QTextCharFormat());
if (TextBlockUserData *userData = TextEditDocumentLayout::testUserData(currentBlock())) {
......@@ -343,7 +343,10 @@ void CppHighlighter::highightLine(const QString &text, int position, int length,
while (index != end && == isSpace);
const int tokenLength = index - start;
setFormat(start, tokenLength, isSpace ? visualSpaceFormat : format);
if (isSpace)
setFormat(start, tokenLength, visualSpaceFormat);
else if (format.isValid())
setFormat(start, tokenLength, format);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment