@@ -18,6 +18,18 @@ internal static class ResultHelper
1818
1919        public  static void  Init ( IPublicAPI  api )  =>  _api  =  api ; 
2020
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+ 
2133        /// <summary> 
2234        /// Return a list with <see cref="Result"/>s, based on the given list. 
2335        /// </summary> 
@@ -31,21 +43,28 @@ internal static List<Result> GetResultList(
3143            string  windowsSettingIconPath , 
3244            string  controlPanelIconPath ) 
3345        { 
46+             if  ( string . IsNullOrWhiteSpace ( query . Search ) ) 
47+             { 
48+                 return  GetDefaultReuslts ( list ,  windowsSettingIconPath ,  controlPanelIconPath ) ; 
49+             } 
50+ 
3451            var  resultList  =  new  List < Result > ( ) ; 
52+ 
3553            foreach  ( var  entry  in  list ) 
3654            { 
3755                // Adjust the score to lower the order of many irrelevant matches from area strings 
3856                // that may only be for description. 
3957                const  int  nonNameMatchScoreAdj  =  10 ; 
4058
59+ 
4160                Result ?  result ; 
4261                Debug . Assert ( _api  !=  null ,  nameof ( _api )  +  " != null" ) ; 
4362
4463                var  nameMatch  =  _api . FuzzySearch ( query . Search ,  entry . Name ) ; 
4564
4665                if  ( nameMatch . IsSearchPrecisionScoreMet ( ) ) 
4766                { 
48-                     var  settingResult  =  NewSettingResult ( nameMatch . Score ,  entry . Type ) ; 
67+                     var  settingResult  =  NewSettingResult ( nameMatch . Score ,  entry . Type ,   windowsSettingIconPath ,   controlPanelIconPath ,   entry ) ; 
4968                    settingResult . TitleHighlightData  =  nameMatch . MatchData ; 
5069                    result  =  settingResult ; 
5170                } 
@@ -54,15 +73,15 @@ internal static List<Result> GetResultList(
5473                    var  areaMatch  =  _api . FuzzySearch ( query . Search ,  entry . Area ) ; 
5574                    if  ( areaMatch . IsSearchPrecisionScoreMet ( ) ) 
5675                    { 
57-                         var  settingResult  =  NewSettingResult ( areaMatch . Score  -  nonNameMatchScoreAdj ,  entry . Type ) ; 
76+                         var  settingResult  =  NewSettingResult ( areaMatch . Score  -  nonNameMatchScoreAdj ,  entry . Type ,   windowsSettingIconPath ,   controlPanelIconPath ,   entry ) ; 
5877                        result  =  settingResult ; 
5978                    } 
6079                    else 
6180                    { 
6281                        result  =  entry . AltNames ? 
6382                            . Select ( altName =>  _api . FuzzySearch ( query . Search ,  altName ) ) 
6483                            . 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 ) ) 
6685                            . FirstOrDefault ( ) ; 
6786                    } 
6887
@@ -76,7 +95,7 @@ internal static List<Result> GetResultList(
7695                                . SelectMany ( x =>  x ) 
7796                                . Contains ( x ,  StringComparer . CurrentCultureIgnoreCase ) ) 
7897                        ) 
79-                             result  =  NewSettingResult ( nonNameMatchScoreAdj ,  entry . Type ) ; 
98+                             result  =  NewSettingResult ( nonNameMatchScoreAdj ,  entry . Type ,   windowsSettingIconPath ,   controlPanelIconPath ,   entry ) ; 
8099                    } 
81100                } 
82101
@@ -86,21 +105,24 @@ internal static List<Result> GetResultList(
86105                AddOptionalToolTip ( entry ,  result ) ; 
87106
88107                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-                 } ; 
99108            } 
100109
101110            return  resultList ; 
102111        } 
103112
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+ 
104126        private  static string  GetSubtitle ( string  section ,  string  entryType ) 
105127        { 
106128            var  settingType  =  entryType  ==  "AppSettingsApp"  ?  "System settings"  :  "Control Panel" ; 
0 commit comments