From 0641dee0947355d4a242364628079a2ae7e042b7 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Fri, 21 Jun 2024 20:43:57 +0200 Subject: [PATCH] runner: Don't match if just one query word matches If someone types in "foo asdf start bar", it should not show the autostart KCM for instance. This runner is part of the default favorites in Plasma 6.1, so it's shown above others and must avoid polluting results. BUG: 488676 --- runner/systemsettingsrunner.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/runner/systemsettingsrunner.cpp b/runner/systemsettingsrunner.cpp index 826194f9..d33b7906 100644 --- a/runner/systemsettingsrunner.cpp +++ b/runner/systemsettingsrunner.cpp @@ -51,12 +51,12 @@ void SystemsettingsRunner::match(KRunner::RunnerContext &context) return true; } for (const QString &queryWord : queryWords) { - if (relevance == -1 && queryWord.length() > 3 && value.contains(queryWord, Qt::CaseInsensitive)) { - relevance = relevanceValue; - return true; + if (!value.contains(queryWord, Qt::CaseInsensitive)) { + return false; } } - return false; + relevance = relevanceValue; + return true; }; const QString name = data.name(); @@ -71,8 +71,8 @@ void SystemsettingsRunner::match(KRunner::RunnerContext &context) } } else if (name.compare(query, Qt::CaseInsensitive) == 0) { relevance = 1; - } else if (checkMatchAndRelevance(name, 0.8)) { // name starts with query or contains any query word - } else if (checkMatchAndRelevance(description, 0.5)) { // description starts with query or contains any query word + } else if (checkMatchAndRelevance(name, 0.8)) { // name starts with query or contains all query words + } else if (checkMatchAndRelevance(description, 0.5)) { // description starts with query or contains all query words } else if (std::any_of(keywords.begin(), keywords.end(), [&query](const QString &keyword) { return keyword.startsWith(query, Qt::CaseInsensitive); })) { -- 2.45.2