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;
|
MatchResult matchResult;
|
||||||
|
|
||||||
// We suppose Name won't be null
|
// 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;
|
title = Name;
|
||||||
matchResult = StringMatcher.FuzzySearch(query, title);
|
matchResult = StringMatcher.FuzzySearch(query, Name);
|
||||||
}
|
|
||||||
else if (Description.StartsWith(Name))
|
|
||||||
{
|
|
||||||
title = Description;
|
|
||||||
matchResult = StringMatcher.FuzzySearch(query, Description);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -401,10 +396,13 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
||||||
}
|
}
|
||||||
matchResult = descriptionMatch;
|
matchResult = descriptionMatch;
|
||||||
}
|
}
|
||||||
else matchResult = nameMatch;
|
else
|
||||||
|
{
|
||||||
|
matchResult = nameMatch;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!matchResult.Success)
|
if (!matchResult.IsSearchPrecisionScoreMet())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var result = new Result
|
var result = new Result
|
||||||
|
|
|
||||||
|
|
@ -90,44 +90,28 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
||||||
bool useLocalizedName = !string.IsNullOrEmpty(LocalizedName) && !Name.Equals(LocalizedName);
|
bool useLocalizedName = !string.IsNullOrEmpty(LocalizedName) && !Name.Equals(LocalizedName);
|
||||||
string resultName = useLocalizedName ? LocalizedName : Name;
|
string resultName = useLocalizedName ? LocalizedName : Name;
|
||||||
|
|
||||||
if (!Main._settings.EnableDescription)
|
if (!Main._settings.EnableDescription || string.IsNullOrWhiteSpace(Description) || resultName.Equals(Description))
|
||||||
{
|
{
|
||||||
title = resultName;
|
title = resultName;
|
||||||
matchResult = StringMatcher.FuzzySearch(query, resultName);
|
matchResult = StringMatcher.FuzzySearch(query, resultName);
|
||||||
}
|
}
|
||||||
else
|
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
|
for (int i = 0; i < descriptionMatch.MatchData.Count; i++)
|
||||||
// Description is always localized, so Name.StartsWith(Description) is generally useless
|
{
|
||||||
title = resultName;
|
descriptionMatch.MatchData[i] += resultName.Length + 2; // 2 is ": "
|
||||||
matchResult = StringMatcher.FuzzySearch(query, resultName);
|
}
|
||||||
}
|
matchResult = descriptionMatch;
|
||||||
else if (Description.StartsWith(resultName))
|
|
||||||
{
|
|
||||||
// resultName included in Description
|
|
||||||
title = Description;
|
|
||||||
matchResult = StringMatcher.FuzzySearch(query, Description);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Search in both
|
matchResult = nameMatch;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue