@@ -179,7 +179,7 @@ public override IListItem[] GetItems()
179179 // and eventually ordered based on user preference
180180 . Concat ( _fallbackItems is not null ?
181181 _fallbackItems
182- . Where ( w => ! string . IsNullOrEmpty ( w . Item . Title ) )
182+ . Where ( w => ! string . IsNullOrWhiteSpace ( w . Item . Title ) )
183183 . OrderByDescending ( o => o . Score ) : [ ] )
184184 . Select ( s => s . Item )
185185 . ToArray ( ) ;
@@ -251,7 +251,7 @@ public override void UpdateSearchText(string oldSearch, string newSearch)
251251
252252 // prefilter fallbacks
253253 var specialFallbacks = new List < TopLevelViewModel > ( ) ;
254- var commonFallbacks = new List < TopLevelViewModel > ( ) ;
254+ var commonFallbacks = new List < Scored < IListItem > > ( ) ;
255255
256256 lock ( _settings )
257257 {
@@ -269,15 +269,15 @@ public override void UpdateSearchText(string oldSearch, string newSearch)
269269 }
270270 else
271271 {
272- commonFallbacks . Add ( s ) ;
272+ commonFallbacks . Add ( new Scored < IListItem > ( ) { Item = s , Score = fallbackSettings . WeightBoost } ) ;
273273 }
274274 }
275275 }
276276
277277 // start update of fallbacks; update special fallbacks separately,
278278 // so they can finish faster
279279 UpdateFallbacks ( SearchText , specialFallbacks , token ) ;
280- UpdateFallbacks ( SearchText , commonFallbacks , token ) ;
280+ UpdateFallbacks ( SearchText , commonFallbacks . Select ( s => s . Item ) . Cast < TopLevelViewModel > ( ) . ToList ( ) , token ) ;
281281
282282 if ( token . IsCancellationRequested )
283283 {
@@ -312,7 +312,7 @@ public override void UpdateSearchText(string oldSearch, string newSearch)
312312 }
313313
314314 var newFilteredItems = Enumerable . Empty < IListItem > ( ) ;
315- var newFallbacks = Enumerable . Empty < IListItem > ( ) ;
315+ var newFallbacks = Enumerable . Empty < Scored < IListItem > > ( ) ;
316316 var newApps = Enumerable . Empty < IListItem > ( ) ;
317317
318318 if ( _filteredItems is not null )
@@ -337,7 +337,7 @@ public override void UpdateSearchText(string oldSearch, string newSearch)
337337
338338 if ( _fallbackItems is not null )
339339 {
340- newFallbacks = _fallbackItems . Select ( s => s . Item ) ;
340+ newFallbacks = _fallbackItems ;
341341 }
342342
343343 if ( token . IsCancellationRequested )
@@ -388,7 +388,7 @@ public override void UpdateSearchText(string oldSearch, string newSearch)
388388 }
389389
390390 var history = _serviceProvider . GetService < AppStateModel > ( ) ! . RecentCommands ! ;
391- Func < string , IListItem , int > scoreTopLevelItem = ( a , b ) => { return ScoreTopLevelItem ( a , b , history , null ) ; } ;
391+ Func < string , IListItem , int > scoreTopLevelItem = ( a , b ) => { return ScoreTopLevelItem ( a , b , history ) ; } ;
392392
393393 // Produce a list of everything that matches the current filter.
394394 _filteredItems = [ .. ListHelpers . FilterListWithScores < IListItem > ( newFilteredItems ?? [ ] , SearchText , scoreTopLevelItem ) ] ;
@@ -405,8 +405,7 @@ public override void UpdateSearchText(string oldSearch, string newSearch)
405405 return ;
406406 }
407407
408- Func < string , IListItem , int > scoreFallbackItem = ( a , b ) => { return ScoreTopLevelItem ( a , b , history , null ) ; } ;
409- _fallbackItems = ListHelpers . FilterListWithScores < IListItem > ( newFallbacks ?? [ ] , SearchText , scoreFallbackItem ) ;
408+ _fallbackItems = newFallbacks ;
410409
411410 if ( token . IsCancellationRequested )
412411 {
@@ -483,7 +482,7 @@ private bool ActuallyLoading()
483482 // Almost verbatim ListHelpers.ScoreListItem, but also accounting for the
484483 // fact that we want fallback handlers down-weighted, so that they don't
485484 // _always_ show up first.
486- internal static int ScoreTopLevelItem ( string query , IListItem topLevelOrAppItem , IRecentCommandsManager history , int ? weightBoost )
485+ internal static int ScoreTopLevelItem ( string query , IListItem topLevelOrAppItem , IRecentCommandsManager history )
487486 {
488487 var title = topLevelOrAppItem . Title ;
489488 if ( string . IsNullOrWhiteSpace ( title ) )
@@ -566,12 +565,6 @@ internal static int ScoreTopLevelItem(string query, IListItem topLevelOrAppItem,
566565 finalScore += recentWeightBoost ;
567566 }
568567
569- // If we're a fallback, we don't care about the rest. Use the weight boost.
570- if ( isFallback && weightBoost is not null )
571- {
572- finalScore = weightBoost . Value ;
573- }
574-
575568 return ( int ) finalScore ;
576569 }
577570
0 commit comments