forked from qt-creator/qt-creator
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
This commit is contained in:
@@ -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 && text.at(index).isSpace() == 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user