Add title & subtitle search

This commit is contained in:
Jack251970 2025-03-13 23:57:52 +08:00
parent e196d7cfa9
commit 0f279df8d3

View file

@ -78,7 +78,23 @@ namespace Flow.Launcher.Plugin.Sys
c.Title = command.Name;
c.SubTitle = command.Description;
var score = _context.API.FuzzySearch(query.Search, command.Keyword).Score;
// Firstly, we will search the localized title & subtitle
var titleMatch = _context.API.FuzzySearch(query.Search, c.Title);
var subTitleMatch = _context.API.FuzzySearch(query.Search, c.SubTitle);
var score = Math.Max(titleMatch.Score, subTitleMatch.Score);
if (score > 0)
{
c.Score = score;
if (score == 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;