From 0069bd733dd06f6a4866ea773141aafdcb1aa1bd Mon Sep 17 00:00:00 2001 From: tiresiasfromthebai Date: Tue, 28 Jul 2026 16:50:29 +0200 Subject: [PATCH] Fix string and class-name syntax highlighting rules --- src/SeerAdaSourceHighlighter.cpp | 4 ++-- src/SeerCppSourceHighlighter.cpp | 12 +++++++----- src/SeerOdinSourceHighlighter.cpp | 12 +++++++----- src/SeerRustSourceHighlighter.cpp | 14 ++++++++------ 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/SeerAdaSourceHighlighter.cpp b/src/SeerAdaSourceHighlighter.cpp index 209da74..ecf97ce 100644 --- a/src/SeerAdaSourceHighlighter.cpp +++ b/src/SeerAdaSourceHighlighter.cpp @@ -55,7 +55,7 @@ void SeerAdaSourceHighlighter::setHighlighterSettings(const SeerHighlighterSetti // Set class format and expression. // (Ada typically doesn't have a distinguished class case convention, but we can reuse uppercase Start) - rule.pattern = QRegularExpression(QStringLiteral("\\b[A-Z][A-z0-9_]*\\b")); + rule.pattern = QRegularExpression(QStringLiteral("\\b[A-Z][A-Za-z0-9_]*\\b")); rule.format = _classFormat; _highlightingRules.append(rule); @@ -74,7 +74,7 @@ void SeerAdaSourceHighlighter::setHighlighterSettings(const SeerHighlighterSetti } // Set quote format and expression. - rule.pattern = QRegularExpression(QStringLiteral("\".*\"")); + rule.pattern = QRegularExpression(QStringLiteral("\"[^\"]*\"")); rule.format = _quotationFormat; _highlightingRules.append(rule); diff --git a/src/SeerCppSourceHighlighter.cpp b/src/SeerCppSourceHighlighter.cpp index 8844ce2..47afad3 100644 --- a/src/SeerCppSourceHighlighter.cpp +++ b/src/SeerCppSourceHighlighter.cpp @@ -79,11 +79,6 @@ void SeerCppSourceHighlighter::setHighlighterSettings (const SeerHighlighterSett rule.format = _classFormat; _highlightingRules.append(rule); - // Set quote format and expression. - rule.pattern = QRegularExpression(QStringLiteral("\".*\"")); - rule.format = _quotationFormat; - _highlightingRules.append(rule); - // Set function format and expression. rule.pattern = QRegularExpression(QStringLiteral("\\b[A-Za-z0-9_]+(?=\\s*\\()")); rule.format = _functionFormat; @@ -96,6 +91,13 @@ void SeerCppSourceHighlighter::setHighlighterSettings (const SeerHighlighterSett _highlightingRules.append(rule); } + // Set quote format and expression. This rule must come after the function + // and keyword rules so that string contents keep the quote format (same + // order as the Ada highlighter). + rule.pattern = QRegularExpression(QStringLiteral("\"[^\"]*\"")); + rule.format = _quotationFormat; + _highlightingRules.append(rule); + // Set single line comment format and expression. rule.pattern = QRegularExpression(QStringLiteral("//[^\n]*")); rule.format = _singleLineCommentFormat; diff --git a/src/SeerOdinSourceHighlighter.cpp b/src/SeerOdinSourceHighlighter.cpp index 77ba231..aeddcf3 100644 --- a/src/SeerOdinSourceHighlighter.cpp +++ b/src/SeerOdinSourceHighlighter.cpp @@ -67,11 +67,6 @@ void SeerOdinSourceHighlighter::setHighlighterSettings (const SeerHighlighterSet rule.format = _classFormat; _highlightingRules.append(rule); - // Set quote format and expression. - rule.pattern = QRegularExpression(QStringLiteral("\".*\"")); - rule.format = _quotationFormat; - _highlightingRules.append(rule); - // Set function format and expression. rule.pattern = QRegularExpression(QStringLiteral("\\b[A-Za-z0-9_]+(?=\\s*\\()")); rule.format = _functionFormat; @@ -84,6 +79,13 @@ void SeerOdinSourceHighlighter::setHighlighterSettings (const SeerHighlighterSet _highlightingRules.append(rule); } + // Set quote format and expression. This rule must come after the function + // and keyword rules so that string contents keep the quote format (same + // order as the Ada highlighter). + rule.pattern = QRegularExpression(QStringLiteral("\"[^\"]*\"")); + rule.format = _quotationFormat; + _highlightingRules.append(rule); + // Set single line comment format and expression. rule.pattern = QRegularExpression(QStringLiteral("//[^\n]*")); rule.format = _singleLineCommentFormat; diff --git a/src/SeerRustSourceHighlighter.cpp b/src/SeerRustSourceHighlighter.cpp index 46751b3..1a4b7b2 100644 --- a/src/SeerRustSourceHighlighter.cpp +++ b/src/SeerRustSourceHighlighter.cpp @@ -57,15 +57,10 @@ void SeerRustSourceHighlighter::setHighlighterSettings(const SeerHighlighterSett HighlightingRule rule; // Set class format and expression. - rule.pattern = QRegularExpression(QStringLiteral("\\b[A-Z][A-z0-9_]*\\b")); + rule.pattern = QRegularExpression(QStringLiteral("\\b[A-Z][A-Za-z0-9_]*\\b")); rule.format = _classFormat; _highlightingRules.append(rule); - // Set quote format and expression. - rule.pattern = QRegularExpression(QStringLiteral("\".*\"")); - rule.format = _quotationFormat; - _highlightingRules.append(rule); - // Set function format and expression. rule.pattern = QRegularExpression(QStringLiteral("\\b[A-Za-z0-9_!]+(?=\\s*\\()")); rule.format = _functionFormat; @@ -78,6 +73,13 @@ void SeerRustSourceHighlighter::setHighlighterSettings(const SeerHighlighterSett _highlightingRules.append(rule); } + // Set quote format and expression. This rule must come after the function + // and keyword rules so that string contents keep the quote format (same + // order as the Ada highlighter). + rule.pattern = QRegularExpression(QStringLiteral("\"[^\"]*\"")); + rule.format = _quotationFormat; + _highlightingRules.append(rule); + // Set single line comment format and expression. rule.pattern = QRegularExpression(QStringLiteral("//[^\n]*")); rule.format = _singleLineCommentFormat;