File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,26 +45,26 @@ Highlighter::Highlighter(QTextDocument *parent,
4545 << " case"
4646 << " catch"
4747 << " char"
48- << " char8_t "
49- << " char16_t "
50- << " char32_t "
48+ << " char8_t "
49+ << " char16_t "
50+ << " char32_t "
5151 << " class"
5252 << " concept"
5353 << " const"
5454 << " consteval"
5555 << " constexpr"
5656 << " constinit"
57- << " const_cast "
57+ << " const_cast "
5858 << " continue"
59- << " co_await "
60- << " co_return "
61- << " co_yield "
59+ << " co_await "
60+ << " co_return "
61+ << " co_yield "
6262 << " decltype"
6363 << " default"
6464 << " delete"
6565 << " do"
6666 << " double"
67- << " dynamic_cast "
67+ << " dynamic_cast "
6868 << " else"
6969 << " enum"
7070 << " explicit"
@@ -92,19 +92,19 @@ Highlighter::Highlighter(QTextDocument *parent,
9292 << " private"
9393 << " protected"
9494 << " public"
95- << " reinterpret_cast "
95+ << " reinterpret_cast "
9696 << " requires"
9797 << " return"
9898 << " short"
9999 << " signed"
100100 << " static"
101- << " static_assert "
102- << " static_cast "
101+ << " static_assert "
102+ << " static_cast "
103103 << " struct"
104104 << " switch"
105105 << " template"
106106 << " this"
107- << " thread_local "
107+ << " thread_local "
108108 << " throw"
109109 << " true"
110110 << " try"
@@ -116,7 +116,7 @@ Highlighter::Highlighter(QTextDocument *parent,
116116 << " virtual"
117117 << " void"
118118 << " volatile"
119- << " wchar_t "
119+ << " wchar_t "
120120 << " while" ;
121121 for (const QString &pattern : keywordPatterns) {
122122 rule.pattern = QRegularExpression (" \\ b" + pattern + " \\ b" );
@@ -157,7 +157,9 @@ Highlighter::Highlighter(QTextDocument *parent,
157157 mSymbolFormat .setBackground (mWidgetStyle ->symbolBGColor );
158158 mSymbolFormat .setFontWeight (mWidgetStyle ->symbolWeight );
159159
160- mCommentStartExpression = QRegularExpression (" /\\ *" );
160+ // We use negative lookbehind assertion `(?<!/)`
161+ // to ignore case: single line comment and line of asterisk
162+ mCommentStartExpression = QRegularExpression (" (?<!/)/\\ *" );
161163 mCommentEndExpression = QRegularExpression (" \\ */" );
162164}
163165
You can’t perform that action at this time.
0 commit comments