@@ -90,44 +90,28 @@ public Result Result(string query, IPublicAPI api)
9090 bool useLocalizedName = ! string . IsNullOrEmpty ( LocalizedName ) && ! Name . Equals ( LocalizedName ) ;
9191 string resultName = useLocalizedName ? LocalizedName : Name ;
9292
93- if ( ! Main . _settings . EnableDescription )
93+ if ( ! Main . _settings . EnableDescription || string . IsNullOrWhiteSpace ( Description ) || resultName . Equals ( Description ) )
9494 {
9595 title = resultName ;
9696 matchResult = StringMatcher . FuzzySearch ( query , resultName ) ;
9797 }
9898 else
9999 {
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 )
101105 {
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 ;
112111 }
113112 else
114113 {
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 ;
131115 }
132116 }
133117
0 commit comments