Skip to content

Commit

Permalink
some regex fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep committed Aug 7, 2024
1 parent 523cb10 commit 08b5a6c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"cwd": "${workspaceFolder}",
"environment": [
{ "name": "XDG_DATA_DIRS", "value": "${workspaceFolder}/app:${env:XDG_DATA_DIRS-/usr/local/share:/usr/share}" },
]
}
]
],
},
],
}
4 changes: 2 additions & 2 deletions app/loghighlighter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ void LogHighlighter::highlightBlock(const QString &text)
for (const auto &rule : m_highlightingRules) {
auto m = rule.pattern.match(text);
while (m.hasMatch()) {
int index = m.lastCapturedIndex();
int index = m.capturedStart();
const int length = m.capturedLength();
setFormat(index, length, rule.format);
m = rule.pattern.match(text, m.lastCapturedIndex());
m = rule.pattern.match(text, m.capturedEnd());
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/tikzeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ void TikzEditor::insertCompletion(const QString &completion)
QString insertWord = completion.right(extra);
const QRegularExpression rx("<[^<>]*>");
const auto m = rx.match(insertWord);
const int offset = m.lastCapturedIndex() - 1; // put cursor at the first option
const int offset = m.capturedStart() - 1; // put cursor at the first option
insertWord.replace(rx, s_completionPlaceHolder);

cursor.insertText(insertWord);
Expand Down
4 changes: 2 additions & 2 deletions app/tikzeditorhighlighter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ void TikzHighlighter::highlightBlock(const QString &text)
auto m = rule.pattern.match(text);
while (m.hasMatch()) {
const int length = m.capturedLength();
const int index = m.lastCapturedIndex();
const int index = m.capturedStart();
if (index == 0 || text.at(index - 1) != QLatin1Char('\\'))
setFormat(index, length, m_formatList[rule.type]);
m = rule.pattern.match(text, index + length);
m = rule.pattern.match(text, m.capturedEnd());
}
}
}
Expand Down

0 comments on commit 08b5a6c

Please sign in to comment.