From 08b5a6ce02a4cf8149beea309ce9a2b30cdd9a0c Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Wed, 7 Aug 2024 12:56:08 +0200 Subject: [PATCH] some regex fixes --- .vscode/launch.json | 6 +++--- app/loghighlighter.cpp | 4 ++-- app/tikzeditor.cpp | 2 +- app/tikzeditorhighlighter.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 7658761..5b4f66d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -13,7 +13,7 @@ "cwd": "${workspaceFolder}", "environment": [ { "name": "XDG_DATA_DIRS", "value": "${workspaceFolder}/app:${env:XDG_DATA_DIRS-/usr/local/share:/usr/share}" }, - ] - } - ] + ], + }, + ], } \ No newline at end of file diff --git a/app/loghighlighter.cpp b/app/loghighlighter.cpp index 571bd68..203c0f9 100644 --- a/app/loghighlighter.cpp +++ b/app/loghighlighter.cpp @@ -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()); } } diff --git a/app/tikzeditor.cpp b/app/tikzeditor.cpp index d700096..ae590a4 100644 --- a/app/tikzeditor.cpp +++ b/app/tikzeditor.cpp @@ -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); diff --git a/app/tikzeditorhighlighter.cpp b/app/tikzeditorhighlighter.cpp index 71f0301..88cca9b 100644 --- a/app/tikzeditorhighlighter.cpp +++ b/app/tikzeditorhighlighter.cpp @@ -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()); } } }