@@ -90,44 +90,28 @@ public Result Result(string query, IPublicAPI api)
90
90
bool useLocalizedName = ! string . IsNullOrEmpty ( LocalizedName ) && ! Name . Equals ( LocalizedName ) ;
91
91
string resultName = useLocalizedName ? LocalizedName : Name ;
92
92
93
- if ( ! Main . _settings . EnableDescription )
93
+ if ( ! Main . _settings . EnableDescription || string . IsNullOrWhiteSpace ( Description ) || resultName . Equals ( Description ) )
94
94
{
95
95
title = resultName ;
96
96
matchResult = StringMatcher . FuzzySearch ( query , resultName ) ;
97
97
}
98
98
else
99
99
{
100
- if ( string . IsNullOrEmpty ( Description ) || resultName . StartsWith ( Description ) )
100
+ // Search in both
101
+ title = $ "{ resultName } : { Description } ";
102
+ var nameMatch = StringMatcher . FuzzySearch ( query , resultName ) ;
103
+ var descriptionMatch = StringMatcher . FuzzySearch ( query , Description ) ;
104
+ if ( descriptionMatch . Score > nameMatch . Score )
101
105
{
102
- // Description is invalid or included in resultName
103
- // Description is always localized, so Name.StartsWith(Description) is generally useless
104
- title = resultName ;
105
- matchResult = StringMatcher . FuzzySearch ( query , resultName ) ;
106
- }
107
- else if ( Description . StartsWith ( resultName ) )
108
- {
109
- // resultName included in Description
110
- title = Description ;
111
- matchResult = StringMatcher . FuzzySearch ( query , Description ) ;
106
+ for ( int i = 0 ; i < descriptionMatch . MatchData . Count ; i ++ )
107
+ {
108
+ descriptionMatch . MatchData [ i ] += resultName . Length + 2 ; // 2 is ": "
109
+ }
110
+ matchResult = descriptionMatch ;
112
111
}
113
112
else
114
113
{
115
- // Search in both
116
- title = $ "{ resultName } : { Description } ";
117
- var nameMatch = StringMatcher . FuzzySearch ( query , resultName ) ;
118
- var descriptionMatch = StringMatcher . FuzzySearch ( query , Description ) ;
119
- if ( descriptionMatch . Score > nameMatch . Score )
120
- {
121
- for ( int i = 0 ; i < descriptionMatch . MatchData . Count ; i ++ )
122
- {
123
- descriptionMatch . MatchData [ i ] += resultName . Length + 2 ; // 2 is ": "
124
- }
125
- matchResult = descriptionMatch ;
126
- }
127
- else
128
- {
129
- matchResult = nameMatch ;
130
- }
114
+ matchResult = nameMatch ;
131
115
}
132
116
}
133
117
0 commit comments