Skip to content

Commit c5cc4ed

Browse files
authored
Merge pull request #1781 from VictoriousRaptor/ShowProgramDesc
Always show/search description in program results if enabled
2 parents c136022 + 8208af4 commit c5cc4ed

File tree

2 files changed

+19
-37
lines changed

2 files changed

+19
-37
lines changed

Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -378,15 +378,10 @@ public Result Result(string query, IPublicAPI api)
378378
MatchResult matchResult;
379379

380380
// We suppose Name won't be null
381-
if (!Main._settings.EnableDescription || Description == null || Name.StartsWith(Description))
381+
if (!Main._settings.EnableDescription || string.IsNullOrWhiteSpace(Description) || Name.Equals(Description))
382382
{
383383
title = Name;
384-
matchResult = StringMatcher.FuzzySearch(query, title);
385-
}
386-
else if (Description.StartsWith(Name))
387-
{
388-
title = Description;
389-
matchResult = StringMatcher.FuzzySearch(query, Description);
384+
matchResult = StringMatcher.FuzzySearch(query, Name);
390385
}
391386
else
392387
{
@@ -401,10 +396,13 @@ public Result Result(string query, IPublicAPI api)
401396
}
402397
matchResult = descriptionMatch;
403398
}
404-
else matchResult = nameMatch;
399+
else
400+
{
401+
matchResult = nameMatch;
402+
}
405403
}
406404

407-
if (!matchResult.Success)
405+
if (!matchResult.IsSearchPrecisionScoreMet())
408406
return null;
409407

410408
var result = new Result

Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -90,44 +90,28 @@ public Result Result(string query, IPublicAPI api)
9090
bool useLocalizedName = !string.IsNullOrEmpty(LocalizedName) && !Name.Equals(LocalizedName);
9191
string resultName = useLocalizedName ? LocalizedName : Name;
9292

93-
if (!Main._settings.EnableDescription)
93+
if (!Main._settings.EnableDescription || string.IsNullOrWhiteSpace(Description) || resultName.Equals(Description))
9494
{
9595
title = resultName;
9696
matchResult = StringMatcher.FuzzySearch(query, resultName);
9797
}
9898
else
9999
{
100-
if (string.IsNullOrEmpty(Description) || resultName.StartsWith(Description))
100+
// Search in both
101+
title = $"{resultName}: {Description}";
102+
var nameMatch = StringMatcher.FuzzySearch(query, resultName);
103+
var descriptionMatch = StringMatcher.FuzzySearch(query, Description);
104+
if (descriptionMatch.Score > nameMatch.Score)
101105
{
102-
// Description is invalid or included in resultName
103-
// Description is always localized, so Name.StartsWith(Description) is generally useless
104-
title = resultName;
105-
matchResult = StringMatcher.FuzzySearch(query, resultName);
106-
}
107-
else if (Description.StartsWith(resultName))
108-
{
109-
// resultName included in Description
110-
title = Description;
111-
matchResult = StringMatcher.FuzzySearch(query, Description);
106+
for (int i = 0; i < descriptionMatch.MatchData.Count; i++)
107+
{
108+
descriptionMatch.MatchData[i] += resultName.Length + 2; // 2 is ": "
109+
}
110+
matchResult = descriptionMatch;
112111
}
113112
else
114113
{
115-
// Search in both
116-
title = $"{resultName}: {Description}";
117-
var nameMatch = StringMatcher.FuzzySearch(query, resultName);
118-
var descriptionMatch = StringMatcher.FuzzySearch(query, Description);
119-
if (descriptionMatch.Score > nameMatch.Score)
120-
{
121-
for (int i = 0; i < descriptionMatch.MatchData.Count; i++)
122-
{
123-
descriptionMatch.MatchData[i] += resultName.Length + 2; // 2 is ": "
124-
}
125-
matchResult = descriptionMatch;
126-
}
127-
else
128-
{
129-
matchResult = nameMatch;
130-
}
114+
matchResult = nameMatch;
131115
}
132116
}
133117

0 commit comments

Comments
 (0)