Skip to content

Commit ab3cd8a

Browse files
committed
Use largest score from title & subtitle & keyword
1 parent 0f279df commit ab3cd8a

File tree

1 file changed

+10
-13
lines changed
  • Plugins/Flow.Launcher.Plugin.Sys

1 file changed

+10
-13
lines changed

Plugins/Flow.Launcher.Plugin.Sys/Main.cs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,26 +78,23 @@ public List<Result> Query(Query query)
7878
c.Title = command.Name;
7979
c.SubTitle = command.Description;
8080

81-
// Firstly, we will search the localized title & subtitle
81+
// Match from localized title & localized subtitle & keyword
8282
var titleMatch = _context.API.FuzzySearch(query.Search, c.Title);
8383
var subTitleMatch = _context.API.FuzzySearch(query.Search, c.SubTitle);
84+
var keywordMatch = _context.API.FuzzySearch(query.Search, command.Keyword);
8485

86+
// Get the largest score from them
8587
var score = Math.Max(titleMatch.Score, subTitleMatch.Score);
86-
if (score > 0)
88+
var finalScore = Math.Max(score, keywordMatch.Score);
89+
if (finalScore > 0)
8790
{
88-
c.Score = score;
91+
c.Score = finalScore;
8992

90-
if (score == titleMatch.Score)
93+
// If title match has the highest score, highlight title
94+
if (finalScore == titleMatch.Score)
95+
{
9196
c.TitleHighlightData = titleMatch.MatchData;
92-
93-
results.Add(c);
94-
}
95-
96-
// If no match found, we will search the keyword
97-
score = _context.API.FuzzySearch(query.Search, command.Keyword).Score;
98-
if (score > 0)
99-
{
100-
c.Score = score;
97+
}
10198

10299
results.Add(c);
103100
}

0 commit comments

Comments
 (0)