@@ -206,12 +206,12 @@ private static IEnumerable<Package> CurrentUserPackages()
206
206
}
207
207
catch ( Exception e )
208
208
{
209
- ProgramLogger . LogException ( "UWP" , "CurrentUserPackages" , $ "id", "An unexpected error occured and "
209
+ ProgramLogger . LogException ( "UWP" , "CurrentUserPackages" , $ "id", "An unexpected error occured and "
210
210
+ $ "unable to verify if package is valid", e ) ;
211
211
return false ;
212
212
}
213
-
214
-
213
+
214
+
215
215
return valid ;
216
216
} ) ;
217
217
return ps ;
@@ -263,24 +263,42 @@ public class Application : IProgram
263
263
public string LogoPath { get ; set ; }
264
264
public UWP Package { get ; set ; }
265
265
266
- public Application ( ) { }
266
+ public Application ( ) { }
267
267
268
268
269
269
public Result Result ( string query , IPublicAPI api )
270
270
{
271
- var title = ( Name , Description ) switch
272
- {
273
- ( var n , null ) => n ,
274
- ( var n , var d ) when d . StartsWith ( n ) => d ,
275
- ( var n , var d ) when n . StartsWith ( d ) => n ,
276
- ( var n , var d ) when ! string . IsNullOrEmpty ( d ) => $ "{ n } : { d } ",
277
- _ => Name
278
- } ;
271
+ string title ;
272
+ MatchResult matchResult ;
279
273
280
- var matchResult = StringMatcher . FuzzySearch ( query , title ) ;
274
+ // We suppose Name won't be null
275
+ if ( Description == null || Name . StartsWith ( Description ) )
276
+ {
277
+ title = Name ;
278
+ matchResult = StringMatcher . FuzzySearch ( query , title ) ;
279
+ }
280
+ else if ( Description . StartsWith ( Name ) )
281
+ {
282
+ title = Description ;
283
+ matchResult = StringMatcher . FuzzySearch ( query , Description ) ;
284
+ }
285
+ else
286
+ {
287
+ title = $ "{ Name } : { Description } ";
288
+ var nameMatch = StringMatcher . FuzzySearch ( query , Name ) ;
289
+ var desciptionMatch = StringMatcher . FuzzySearch ( query , Description ) ;
290
+ if ( desciptionMatch . Score > nameMatch . Score )
291
+ {
292
+ for ( int i = 0 ; i < desciptionMatch . MatchData . Count ; i ++ )
293
+ {
294
+ desciptionMatch . MatchData [ i ] += Name . Length + 2 ; // 2 is ": "
295
+ }
296
+ matchResult = desciptionMatch ;
297
+ }
298
+ else matchResult = nameMatch ;
299
+ }
281
300
282
- if ( ! matchResult . Success )
283
- return null ;
301
+ if ( ! matchResult . Success ) return null ;
284
302
285
303
var result = new Result
286
304
{
@@ -311,7 +329,7 @@ public List<Result> ContextMenus(IPublicAPI api)
311
329
312
330
Action = _ =>
313
331
{
314
- Main . StartProcess ( Process . Start ,
332
+ Main . StartProcess ( Process . Start ,
315
333
new ProcessStartInfo (
316
334
! string . IsNullOrEmpty ( Main . _settings . CustomizedExplorer )
317
335
? Main . _settings . CustomizedExplorer
@@ -403,14 +421,14 @@ internal string ResourceFromPri(string packageFullName, string packageName, stri
403
421
public string FormattedPriReferenceValue ( string packageName , string rawPriReferenceValue )
404
422
{
405
423
const string prefix = "ms-resource:" ;
406
-
424
+
407
425
if ( string . IsNullOrWhiteSpace ( rawPriReferenceValue ) || ! rawPriReferenceValue . StartsWith ( prefix ) )
408
426
return rawPriReferenceValue ;
409
427
410
428
string key = rawPriReferenceValue . Substring ( prefix . Length ) ;
411
429
if ( key . StartsWith ( "//" ) )
412
430
return $ "{ prefix } { key } ";
413
-
431
+
414
432
if ( ! key . StartsWith ( "/" ) )
415
433
{
416
434
key = $ "/{ key } ";
0 commit comments