forked from qt-creator/qt-creator
CppEditor: fix highlighter tests
amends 9091c99429
Change-Id: Iaa64d51aa0dad1d63c88a51bfa55afa2367e65ed
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -621,8 +621,9 @@ void CppHighlighterTest::test()
|
|||||||
const QChar c = m_doc.characterAt(pos);
|
const QChar c = m_doc.characterAt(pos);
|
||||||
if (c == QChar::ParagraphSeparator)
|
if (c == QChar::ParagraphSeparator)
|
||||||
continue;
|
continue;
|
||||||
const QTextCharFormat expectedFormat = c.isSpace()
|
const QTextCharFormat expectedFormat = asSyntaxHighlight(
|
||||||
? whitespacified(formatForStyle) : formatForStyle;
|
c.isSpace() ? whitespacified(formatForStyle) : formatForStyle);
|
||||||
|
|
||||||
const QTextCharFormat actualFormat = getActualFormat(pos);
|
const QTextCharFormat actualFormat = getActualFormat(pos);
|
||||||
if (actualFormat != expectedFormat) {
|
if (actualFormat != expectedFormat) {
|
||||||
int posLine;
|
int posLine;
|
||||||
|
@@ -869,6 +869,13 @@ QTextCharFormat SyntaxHighlighter::whitespacified(const QTextCharFormat &fmt)
|
|||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTextCharFormat SyntaxHighlighter::asSyntaxHighlight(const QTextCharFormat &fmt)
|
||||||
|
{
|
||||||
|
QTextCharFormat format = fmt;
|
||||||
|
format.setProperty(SyntaxHighlight, true);
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
void SyntaxHighlighter::highlightBlock(const QString &text)
|
void SyntaxHighlighter::highlightBlock(const QString &text)
|
||||||
{
|
{
|
||||||
formatSpaces(text);
|
formatSpaces(text);
|
||||||
|
@@ -62,6 +62,7 @@ protected:
|
|||||||
void setTextFormatCategories(int count, std::function<TextStyle(int)> formatMapping);
|
void setTextFormatCategories(int count, std::function<TextStyle(int)> formatMapping);
|
||||||
QTextCharFormat formatForCategory(int categoryIndex) const;
|
QTextCharFormat formatForCategory(int categoryIndex) const;
|
||||||
QTextCharFormat whitespacified(const QTextCharFormat &fmt);
|
QTextCharFormat whitespacified(const QTextCharFormat &fmt);
|
||||||
|
QTextCharFormat asSyntaxHighlight(const QTextCharFormat &fmt);
|
||||||
|
|
||||||
// implement in subclasses
|
// implement in subclasses
|
||||||
// default implementation highlights whitespace
|
// default implementation highlights whitespace
|
||||||
|
Reference in New Issue
Block a user