Skip to content

Commit 0f279df

Browse files
committed
Add title & subtitle search
1 parent e196d7c commit 0f279df

File tree

1 file changed

+17
-1
lines changed
  • Plugins/Flow.Launcher.Plugin.Sys

1 file changed

+17
-1
lines changed

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

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

81-
var score = _context.API.FuzzySearch(query.Search, command.Keyword).Score;
81+
// Firstly, we will search the localized title & subtitle
82+
var titleMatch = _context.API.FuzzySearch(query.Search, c.Title);
83+
var subTitleMatch = _context.API.FuzzySearch(query.Search, c.SubTitle);
84+
85+
var score = Math.Max(titleMatch.Score, subTitleMatch.Score);
86+
if (score > 0)
87+
{
88+
c.Score = score;
89+
90+
if (score == titleMatch.Score)
91+
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;
8298
if (score > 0)
8399
{
84100
c.Score = score;

0 commit comments

Comments
 (0)