Codeeditor class improvements (#4057)

This commit is contained in:
Maksim Derbasov 2022-04-29 19:10:37 +03:00 committed by GitHub
parent e7afb3045b
commit 3ca2eb984e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -71,20 +71,24 @@ Highlighter::Highlighter(QTextDocument *parent,
<< "export"
<< "extern"
<< "false"
<< "final"
<< "float"
<< "for"
<< "friend"
<< "goto"
<< "if"
<< "import"
<< "inline"
<< "int"
<< "long"
<< "module"
<< "mutable"
<< "namespace"
<< "new"
<< "noexcept"
<< "nullptr"
<< "operator"
<< "override"
<< "private"
<< "protected"
<< "public"
@ -130,7 +134,9 @@ Highlighter::Highlighter(QTextDocument *parent,
mQuotationFormat.setForeground(mWidgetStyle->quoteColor);
mQuotationFormat.setFontWeight(mWidgetStyle->quoteWeight);
rule.pattern = QRegularExpression("\".*\"");
// We use lazy `*?` instead greed `*` quantifier to find the real end of the c-string.
// We use negative lookbehind assertion `(?<!\)` to ignore `\"` sequience in the c-string.
rule.pattern = QRegularExpression("\".*?(?<!\\\\)\"");
rule.format = mQuotationFormat;
rule.ruleRole = RuleRole::Quote;
mHighlightingRules.append(rule);