@@ -18,6 +18,18 @@ internal static class ResultHelper
18
18
19
19
public static void Init ( IPublicAPI api ) => _api = api ;
20
20
21
+ private static List < Result > GetDefaultReuslts ( in IEnumerable < WindowsSetting > list ,
22
+ string windowsSettingIconPath ,
23
+ string controlPanelIconPath )
24
+ {
25
+ return list . Select ( entry =>
26
+ {
27
+ var result = NewSettingResult ( 100 , entry . Type , windowsSettingIconPath , controlPanelIconPath , entry ) ;
28
+ AddOptionalToolTip ( entry , result ) ;
29
+ return result ;
30
+ } ) . ToList ( ) ;
31
+ }
32
+
21
33
/// <summary>
22
34
/// Return a list with <see cref="Result"/>s, based on the given list.
23
35
/// </summary>
@@ -31,21 +43,28 @@ internal static List<Result> GetResultList(
31
43
string windowsSettingIconPath ,
32
44
string controlPanelIconPath )
33
45
{
46
+ if ( string . IsNullOrWhiteSpace ( query . Search ) )
47
+ {
48
+ return GetDefaultReuslts ( list , windowsSettingIconPath , controlPanelIconPath ) ;
49
+ }
50
+
34
51
var resultList = new List < Result > ( ) ;
52
+
35
53
foreach ( var entry in list )
36
54
{
37
55
// Adjust the score to lower the order of many irrelevant matches from area strings
38
56
// that may only be for description.
39
57
const int nonNameMatchScoreAdj = 10 ;
40
58
59
+
41
60
Result ? result ;
42
61
Debug . Assert ( _api != null , nameof ( _api ) + " != null" ) ;
43
62
44
63
var nameMatch = _api . FuzzySearch ( query . Search , entry . Name ) ;
45
64
46
65
if ( nameMatch . IsSearchPrecisionScoreMet ( ) )
47
66
{
48
- var settingResult = NewSettingResult ( nameMatch . Score , entry . Type ) ;
67
+ var settingResult = NewSettingResult ( nameMatch . Score , entry . Type , windowsSettingIconPath , controlPanelIconPath , entry ) ;
49
68
settingResult . TitleHighlightData = nameMatch . MatchData ;
50
69
result = settingResult ;
51
70
}
@@ -54,15 +73,15 @@ internal static List<Result> GetResultList(
54
73
var areaMatch = _api . FuzzySearch ( query . Search , entry . Area ) ;
55
74
if ( areaMatch . IsSearchPrecisionScoreMet ( ) )
56
75
{
57
- var settingResult = NewSettingResult ( areaMatch . Score - nonNameMatchScoreAdj , entry . Type ) ;
76
+ var settingResult = NewSettingResult ( areaMatch . Score - nonNameMatchScoreAdj , entry . Type , windowsSettingIconPath , controlPanelIconPath , entry ) ;
58
77
result = settingResult ;
59
78
}
60
79
else
61
80
{
62
81
result = entry . AltNames ?
63
82
. Select ( altName => _api . FuzzySearch ( query . Search , altName ) )
64
83
. Where ( match => match . IsSearchPrecisionScoreMet ( ) )
65
- . Select ( altNameMatch => NewSettingResult ( altNameMatch . Score - nonNameMatchScoreAdj , entry . Type ) )
84
+ . Select ( altNameMatch => NewSettingResult ( altNameMatch . Score - nonNameMatchScoreAdj , entry . Type , windowsSettingIconPath , controlPanelIconPath , entry ) )
66
85
. FirstOrDefault ( ) ;
67
86
}
68
87
@@ -76,7 +95,7 @@ internal static List<Result> GetResultList(
76
95
. SelectMany ( x => x )
77
96
. Contains ( x , StringComparer . CurrentCultureIgnoreCase ) )
78
97
)
79
- result = NewSettingResult ( nonNameMatchScoreAdj , entry . Type ) ;
98
+ result = NewSettingResult ( nonNameMatchScoreAdj , entry . Type , windowsSettingIconPath , controlPanelIconPath , entry ) ;
80
99
}
81
100
}
82
101
@@ -86,21 +105,24 @@ internal static List<Result> GetResultList(
86
105
AddOptionalToolTip ( entry , result ) ;
87
106
88
107
resultList . Add ( result ) ;
89
-
90
- Result NewSettingResult ( int score , string type ) => new ( )
91
- {
92
- Action = _ => DoOpenSettingsAction ( entry ) ,
93
- IcoPath = type == "AppSettingsApp" ? windowsSettingIconPath : controlPanelIconPath ,
94
- SubTitle = GetSubtitle ( entry . Area , type ) ,
95
- Title = entry . Name + entry . glyph ,
96
- ContextData = entry ,
97
- Score = score
98
- } ;
99
108
}
100
109
101
110
return resultList ;
102
111
}
103
112
113
+ private const int TaskLinkScorePanelty = 50 ;
114
+
115
+ private static Result NewSettingResult ( int score , string type , string windowsSettingIconPath , string controlPanelIconPath , WindowsSetting entry ) => new ( )
116
+ {
117
+ Action = _ => DoOpenSettingsAction ( entry ) ,
118
+ IcoPath = type == "AppSettingsApp" ? windowsSettingIconPath : controlPanelIconPath ,
119
+ Glyph = entry . IconGlyph ,
120
+ SubTitle = GetSubtitle ( entry . Area , type ) ,
121
+ Title = entry . Name ,
122
+ ContextData = entry ,
123
+ Score = score - ( type == "TaskLink" ? TaskLinkScorePanelty : 0 ) ,
124
+ } ;
125
+
104
126
private static string GetSubtitle ( string section , string entryType )
105
127
{
106
128
var settingType = entryType == "AppSettingsApp" ? "System settings" : "Control Panel" ;
0 commit comments