From 4a7f06c968db73b5dc9588eec980e03c948ba653 Mon Sep 17 00:00:00 2001 From: crackedmind Date: Wed, 3 Mar 2021 21:21:12 +0500 Subject: [PATCH] highlighter: improve string interpolation --- vcreatorhighlighter.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/vcreatorhighlighter.cpp b/vcreatorhighlighter.cpp index e5898ab..bb789c6 100644 --- a/vcreatorhighlighter.cpp +++ b/vcreatorhighlighter.cpp @@ -37,13 +37,13 @@ void VlangHighlighter::highlightBlock(const QString &text) case Token::String: { QRegularExpression re(R"del((\$([\w.]+|\{.*?\})))del"); QString t = text.mid(token.offset, token.length); - auto match = re.match(t); - if(match.hasMatch()) { - setFormat(token.offset, token.offset + match.capturedStart(1), formatForCategory(TextEditor::C_STRING)); - setFormat(token.offset + match.capturedStart(1), match.capturedEnd(1), formatForCategory(TextEditor::C_TYPE)); - setFormat(token.offset + match.capturedEnd(1), token.length - match.capturedEnd(1), formatForCategory(TextEditor::C_STRING)); - } else { - setFormat(token.offset, token.length, formatForCategory(TextEditor::C_STRING)); + auto it = re.globalMatch(t); + int matches = 0; + setFormat(token.offset, token.length, formatForCategory(TextEditor::C_STRING)); + while(it.hasNext()) { + auto match = it.next(); + setFormat(token.offset + match.capturedStart(1), match.capturedEnd(1) - match.capturedStart(1), formatForCategory(TextEditor::C_TYPE)); + matches++; } } break;