From ab3cd8a329c2626c19e6d7339470df14d472f3e5 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Fri, 14 Mar 2025 15:32:23 +0800 Subject: [PATCH] Use largest score from title & subtitle & keyword --- Plugins/Flow.Launcher.Plugin.Sys/Main.cs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs index d716484bb..77f3b56a6 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs @@ -78,26 +78,23 @@ namespace Flow.Launcher.Plugin.Sys c.Title = command.Name; c.SubTitle = command.Description; - // Firstly, we will search the localized title & subtitle + // Match from localized title & localized subtitle & keyword var titleMatch = _context.API.FuzzySearch(query.Search, c.Title); var subTitleMatch = _context.API.FuzzySearch(query.Search, c.SubTitle); + var keywordMatch = _context.API.FuzzySearch(query.Search, command.Keyword); + // Get the largest score from them var score = Math.Max(titleMatch.Score, subTitleMatch.Score); - if (score > 0) + var finalScore = Math.Max(score, keywordMatch.Score); + if (finalScore > 0) { - c.Score = score; + c.Score = finalScore; - if (score == titleMatch.Score) + // If title match has the highest score, highlight title + if (finalScore == titleMatch.Score) + { c.TitleHighlightData = titleMatch.MatchData; - - results.Add(c); - } - - // If no match found, we will search the keyword - score = _context.API.FuzzySearch(query.Search, command.Keyword).Score; - if (score > 0) - { - c.Score = score; + } results.Add(c); }