Commit f956c236 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

runners/webshortcuts: Do not use static regex for normal webshortcuts query

The delimiter might change if the settings are changed.
By having a member variable, we still avoid re-creating the same regex for every time the runner is queried.

BUG: 454596


(cherry picked from commit a5378b52)
parent 0b23a298
Pipeline #184171 passed with stage
in 12 minutes and 13 seconds
......@@ -46,6 +46,7 @@ void WebshortcutRunner::loadSyntaxes()
if (KUriFilter::self()->filterSearchUri(filterData, KUriFilter::NormalTextFilter)) {
m_delimiter = filterData.searchTermSeparator();
}
m_regex = QRegularExpression(QStringLiteral("^([^ ]+)%1").arg(QRegularExpression::escape(m_delimiter)));
QList<Plasma::RunnerSyntax> syns;
const QStringList providers = filterData.preferredSearchProviders();
......@@ -101,7 +102,6 @@ void WebshortcutRunner::match(Plasma::RunnerContext &context)
{
const QString term = context.query();
const static QRegularExpression bangRegex(QStringLiteral("!([^ ]+).*"));
const static QRegularExpression normalRegex(QStringLiteral("^([^ ]+)%1").arg(QRegularExpression::escape(m_delimiter)));
const auto bangMatch = bangRegex.match(term);
QString key;
QString rawQuery = term;
......@@ -110,7 +110,7 @@ void WebshortcutRunner::match(Plasma::RunnerContext &context)
key = bangMatch.captured(1);
rawQuery = rawQuery.remove(rawQuery.indexOf(key) - 1, key.size() + 1);
} else {
const auto normalMatch = normalRegex.match(term);
const auto normalMatch = m_regex.match(term);
if (normalMatch.hasMatch()) {
key = normalMatch.captured(0);
rawQuery = rawQuery.mid(key.length());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment