Skip to content

Commit 3ca2eb9

Browse files
authored
Codeeditor class improvements (#4057)
1 parent e7afb30 commit 3ca2eb9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

gui/codeeditor.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,24 @@ Highlighter::Highlighter(QTextDocument *parent,
7171
<< "export"
7272
<< "extern"
7373
<< "false"
74+
<< "final"
7475
<< "float"
7576
<< "for"
7677
<< "friend"
7778
<< "goto"
7879
<< "if"
80+
<< "import"
7981
<< "inline"
8082
<< "int"
8183
<< "long"
84+
<< "module"
8285
<< "mutable"
8386
<< "namespace"
8487
<< "new"
8588
<< "noexcept"
8689
<< "nullptr"
8790
<< "operator"
91+
<< "override"
8892
<< "private"
8993
<< "protected"
9094
<< "public"
@@ -130,7 +134,9 @@ Highlighter::Highlighter(QTextDocument *parent,
130134

131135
mQuotationFormat.setForeground(mWidgetStyle->quoteColor);
132136
mQuotationFormat.setFontWeight(mWidgetStyle->quoteWeight);
133-
rule.pattern = QRegularExpression("\".*\"");
137+
// We use lazy `*?` instead greed `*` quantifier to find the real end of the c-string.
138+
// We use negative lookbehind assertion `(?<!\)` to ignore `\"` sequience in the c-string.
139+
rule.pattern = QRegularExpression("\".*?(?<!\\\\)\"");
134140
rule.format = mQuotationFormat;
135141
rule.ruleRole = RuleRole::Quote;
136142
mHighlightingRules.append(rule);

0 commit comments

Comments
 (0)