Skip to content

Commit 6ad1bca

Browse files
committed
lower non-name matched results and use fuzzy scores for name matches
1 parent 11f1f40 commit 6ad1bca

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Plugins/Flow.Launcher.Plugin.WindowsSettings/Helper/ResultHelper.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ internal static List<Result> GetResultList(
3434
var resultList = new List<Result>();
3535
foreach (var entry in list)
3636
{
37-
const int highScore = 20;
38-
const int midScore = 10;
37+
// Adjust the score to lower the order of many irrelevant matches from area strings
38+
// that may only be for description.
39+
const int nonNameMatchScoreAdj = 10;
3940

4041
Result? result;
4142
Debug.Assert(_api != null, nameof(_api) + " != null");
@@ -44,7 +45,7 @@ internal static List<Result> GetResultList(
4445

4546
if (nameMatch.IsSearchPrecisionScoreMet())
4647
{
47-
var settingResult = NewSettingResult(nameMatch.Score + highScore, entry.Type);
48+
var settingResult = NewSettingResult(nameMatch.Score, entry.Type);
4849
settingResult.TitleHighlightData = nameMatch.MatchData;
4950
result = settingResult;
5051
}
@@ -53,15 +54,15 @@ internal static List<Result> GetResultList(
5354
var areaMatch = _api.FuzzySearch(query.Search, entry.Area);
5455
if (areaMatch.IsSearchPrecisionScoreMet())
5556
{
56-
var settingResult = NewSettingResult(areaMatch.Score + midScore, entry.Type);
57+
var settingResult = NewSettingResult(areaMatch.Score - nonNameMatchScoreAdj, entry.Type);
5758
result = settingResult;
5859
}
5960
else
6061
{
6162
result = entry.AltNames?
6263
.Select(altName => _api.FuzzySearch(query.Search, altName))
6364
.Where(match => match.IsSearchPrecisionScoreMet())
64-
.Select(altNameMatch => NewSettingResult(altNameMatch.Score + midScore, entry.Type))
65+
.Select(altNameMatch => NewSettingResult(altNameMatch.Score - nonNameMatchScoreAdj, entry.Type))
6566
.FirstOrDefault();
6667
}
6768

@@ -75,7 +76,7 @@ internal static List<Result> GetResultList(
7576
.SelectMany(x => x)
7677
.Contains(x, StringComparer.CurrentCultureIgnoreCase))
7778
)
78-
result = NewSettingResult(midScore, entry.Type);
79+
result = NewSettingResult(nonNameMatchScoreAdj, entry.Type);
7980
}
8081
}
8182

@@ -115,7 +116,7 @@ private static string GetSubtitle(string section, string entryType)
115116
private static void AddOptionalToolTip(WindowsSetting entry, Result result)
116117
{
117118
var toolTipText = new StringBuilder();
118-
119+
119120
var settingType = entry.Type == "AppSettingsApp" ? "System settings" : "Control Panel";
120121

121122
toolTipText.AppendLine($"{Resources.Application}: {settingType}");

0 commit comments

Comments
 (0)