Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Commit

Permalink
highlighter: improve string interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
crackedmind committed Mar 3, 2021
1 parent 05d3c91 commit 4a7f06c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions vcreatorhighlighter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4a7f06c

Please sign in to comment.