@@ -54,51 +54,43 @@ public class Win32 : IProgram, IEquatable<Win32>
54
54
public Result Result ( string query , IPublicAPI api )
55
55
{
56
56
string title ;
57
-
58
- var nameMatchResult = StringMatcher . FuzzySearch ( query , Name ) ;
59
- var descriptionMatchResult = StringMatcher . FuzzySearch ( query , Description ) ;
60
-
61
- var pathMatchResult = new MatchResult ( false , 0 , new List < int > ( ) , 0 ) ;
62
- if ( ExecutableName != null ) // only lnk program will need this one
63
- pathMatchResult = StringMatcher . FuzzySearch ( query , ExecutableName ) ;
64
-
65
- MatchResult matchResult = nameMatchResult ;
66
-
67
- if ( nameMatchResult . Score < descriptionMatchResult . Score )
68
- matchResult = descriptionMatchResult ;
69
-
70
- if ( ! matchResult . IsSearchPrecisionScoreMet ( ) )
71
- {
72
- if ( pathMatchResult . IsSearchPrecisionScoreMet ( ) )
73
- matchResult = pathMatchResult ;
74
- else return null ;
75
- }
57
+ MatchResult matchResult ;
76
58
77
59
// We suppose Name won't be null
78
- if ( Description == null || Name . StartsWith ( Description ) )
60
+ if ( ! Main . _settings . EnableDescription || Description == null || Name . StartsWith ( Description ) )
79
61
{
80
62
title = Name ;
63
+ matchResult = StringMatcher . FuzzySearch ( query , title ) ;
81
64
}
82
65
else if ( Description . StartsWith ( Name ) )
83
66
{
84
67
title = Description ;
68
+ matchResult = StringMatcher . FuzzySearch ( query , Description ) ;
85
69
}
86
70
else
87
71
{
88
72
title = $ "{ Name } : { Description } ";
89
-
90
- if ( matchResult == descriptionMatchResult )
73
+ var nameMatch = StringMatcher . FuzzySearch ( query , Name ) ;
74
+ var desciptionMatch = StringMatcher . FuzzySearch ( query , Description ) ;
75
+ if ( desciptionMatch . Score > nameMatch . Score )
91
76
{
92
- for ( int i = 0 ; i < descriptionMatchResult . MatchData . Count ; i ++ )
77
+ for ( int i = 0 ; i < desciptionMatch . MatchData . Count ; i ++ )
93
78
{
94
- matchResult . MatchData [ i ] += Name . Length + 2 ; // 2 is ": "
79
+ desciptionMatch . MatchData [ i ] += Name . Length + 2 ; // 2 is ": "
95
80
}
81
+ matchResult = desciptionMatch ;
96
82
}
83
+ else matchResult = nameMatch ;
97
84
}
98
85
99
- if ( matchResult == pathMatchResult )
86
+ if ( ! matchResult . IsSearchPrecisionScoreMet ( ) )
100
87
{
101
- // path Match won't have valid highlight data
88
+ if ( ExecutableName != null ) // only lnk program will need this one
89
+ matchResult = StringMatcher . FuzzySearch ( query , ExecutableName ) ;
90
+
91
+ if ( ! matchResult . IsSearchPrecisionScoreMet ( ) )
92
+ return null ;
93
+
102
94
matchResult . MatchData = new List < int > ( ) ;
103
95
}
104
96
0 commit comments