mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Always show/search desc in result if enabled
This commit is contained in:
parent
5e0adbaf36
commit
8208af4d1a
2 changed files with 19 additions and 37 deletions
|
|
@ -378,15 +378,10 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
MatchResult matchResult;
|
||||
|
||||
// We suppose Name won't be null
|
||||
if (!Main._settings.EnableDescription || Description == null || Name.StartsWith(Description))
|
||||
if (!Main._settings.EnableDescription || string.IsNullOrWhiteSpace(Description) || Name.Equals(Description))
|
||||
{
|
||||
title = Name;
|
||||
matchResult = StringMatcher.FuzzySearch(query, title);
|
||||
}
|
||||
else if (Description.StartsWith(Name))
|
||||
{
|
||||
title = Description;
|
||||
matchResult = StringMatcher.FuzzySearch(query, Description);
|
||||
matchResult = StringMatcher.FuzzySearch(query, Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -401,10 +396,13 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
}
|
||||
matchResult = descriptionMatch;
|
||||
}
|
||||
else matchResult = nameMatch;
|
||||
else
|
||||
{
|
||||
matchResult = nameMatch;
|
||||
}
|
||||
}
|
||||
|
||||
if (!matchResult.Success)
|
||||
if (!matchResult.IsSearchPrecisionScoreMet())
|
||||
return null;
|
||||
|
||||
var result = new Result
|
||||
|
|
|
|||
|
|
@ -90,44 +90,28 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
bool useLocalizedName = !string.IsNullOrEmpty(LocalizedName) && !Name.Equals(LocalizedName);
|
||||
string resultName = useLocalizedName ? LocalizedName : Name;
|
||||
|
||||
if (!Main._settings.EnableDescription)
|
||||
if (!Main._settings.EnableDescription || string.IsNullOrWhiteSpace(Description) || resultName.Equals(Description))
|
||||
{
|
||||
title = resultName;
|
||||
matchResult = StringMatcher.FuzzySearch(query, resultName);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(Description) || resultName.StartsWith(Description))
|
||||
// Search in both
|
||||
title = $"{resultName}: {Description}";
|
||||
var nameMatch = StringMatcher.FuzzySearch(query, resultName);
|
||||
var descriptionMatch = StringMatcher.FuzzySearch(query, Description);
|
||||
if (descriptionMatch.Score > nameMatch.Score)
|
||||
{
|
||||
// Description is invalid or included in resultName
|
||||
// Description is always localized, so Name.StartsWith(Description) is generally useless
|
||||
title = resultName;
|
||||
matchResult = StringMatcher.FuzzySearch(query, resultName);
|
||||
}
|
||||
else if (Description.StartsWith(resultName))
|
||||
{
|
||||
// resultName included in Description
|
||||
title = Description;
|
||||
matchResult = StringMatcher.FuzzySearch(query, Description);
|
||||
for (int i = 0; i < descriptionMatch.MatchData.Count; i++)
|
||||
{
|
||||
descriptionMatch.MatchData[i] += resultName.Length + 2; // 2 is ": "
|
||||
}
|
||||
matchResult = descriptionMatch;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Search in both
|
||||
title = $"{resultName}: {Description}";
|
||||
var nameMatch = StringMatcher.FuzzySearch(query, resultName);
|
||||
var descriptionMatch = StringMatcher.FuzzySearch(query, Description);
|
||||
if (descriptionMatch.Score > nameMatch.Score)
|
||||
{
|
||||
for (int i = 0; i < descriptionMatch.MatchData.Count; i++)
|
||||
{
|
||||
descriptionMatch.MatchData[i] += resultName.Length + 2; // 2 is ": "
|
||||
}
|
||||
matchResult = descriptionMatch;
|
||||
}
|
||||
else
|
||||
{
|
||||
matchResult = nameMatch;
|
||||
}
|
||||
matchResult = nameMatch;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue