@@ -41,8 +41,8 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
41
41
var results = new List < Result > ( ) ;
42
42
43
43
foreach ( SearchSource searchSource in _settings . SearchSources . Where ( o => ( o . ActionKeyword == query . ActionKeyword ||
44
- o . ActionKeyword == SearchSourceGlobalPluginWildCardSign )
45
- && o . Enabled ) )
44
+ o . ActionKeyword == SearchSourceGlobalPluginWildCardSign )
45
+ && o . Enabled ) )
46
46
{
47
47
string keyword = string . Empty ;
48
48
keyword = searchSource . ActionKeyword == SearchSourceGlobalPluginWildCardSign ? query . ToString ( ) : query . Search ;
@@ -85,8 +85,7 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
85
85
86
86
ResultsUpdated ? . Invoke ( this , new ResultUpdatedEventArgs
87
87
{
88
- Results = results ,
89
- Query = query
88
+ Results = results , Query = query
90
89
} ) ;
91
90
92
91
await UpdateResultsFromSuggestionAsync ( results , keyword , subtitle , searchSource , query , token ) . ConfigureAwait ( false ) ;
@@ -105,11 +104,11 @@ private async Task UpdateResultsFromSuggestionAsync(List<Result> results, string
105
104
if ( _settings . EnableSuggestion )
106
105
{
107
106
var suggestions = await SuggestionsAsync ( keyword , subtitle , searchSource , token ) . ConfigureAwait ( false ) ;
108
- if ( token . IsCancellationRequested || ! suggestions . Any ( ) )
107
+ var enumerable = suggestions ? . ToList ( ) ;
108
+ if ( token . IsCancellationRequested || enumerable is not { Count : > 0 } )
109
109
return ;
110
-
111
-
112
- results . AddRange ( suggestions ) ;
110
+
111
+ results . AddRange ( enumerable ) ;
113
112
114
113
token . ThrowIfCancellationRequested ( ) ;
115
114
}
@@ -118,32 +117,31 @@ private async Task UpdateResultsFromSuggestionAsync(List<Result> results, string
118
117
private async Task < IEnumerable < Result > > SuggestionsAsync ( string keyword , string subtitle , SearchSource searchSource , CancellationToken token )
119
118
{
120
119
var source = _settings . SelectedSuggestion ;
121
- if ( source ! = null )
120
+ if ( source = = null )
122
121
{
123
- //Suggestions appear below actual result, and appear above global action keyword match if non-global;
124
- var score = searchSource . ActionKeyword == SearchSourceGlobalPluginWildCardSign ? scoreSuggestions : scoreSuggestions + 1 ;
122
+ return new List < Result > ( ) ;
123
+ }
124
+ //Suggestions appear below actual result, and appear above global action keyword match if non-global;
125
+ var score = searchSource . ActionKeyword == SearchSourceGlobalPluginWildCardSign ? scoreSuggestions : scoreSuggestions + 1 ;
125
126
126
- var suggestions = await source . Suggestions ( keyword , token ) . ConfigureAwait ( false ) ;
127
+ var suggestions = await source . SuggestionsAsync ( keyword , token ) . ConfigureAwait ( false ) ;
127
128
128
- token . ThrowIfCancellationRequested ( ) ;
129
+ token . ThrowIfCancellationRequested ( ) ;
129
130
130
- var resultsFromSuggestion = suggestions ? . Select ( o => new Result
131
+ var resultsFromSuggestion = suggestions ? . Select ( o => new Result
132
+ {
133
+ Title = o ,
134
+ SubTitle = subtitle ,
135
+ Score = score ,
136
+ IcoPath = searchSource . IconPath ,
137
+ Action = c =>
131
138
{
132
- Title = o ,
133
- SubTitle = subtitle ,
134
- Score = score ,
135
- IcoPath = searchSource . IconPath ,
136
- ActionKeywordAssigned = searchSource . ActionKeyword == SearchSourceGlobalPluginWildCardSign ? string . Empty : searchSource . ActionKeyword ,
137
- Action = c =>
138
- {
139
- _context . API . OpenUrl ( searchSource . Url . Replace ( "{q}" , Uri . EscapeDataString ( o ) ) ) ;
139
+ _context . API . OpenUrl ( searchSource . Url . Replace ( "{q}" , Uri . EscapeDataString ( o ) ) ) ;
140
140
141
- return true ;
142
- }
143
- } ) ;
144
- return resultsFromSuggestion ;
145
- }
146
- return new List < Result > ( ) ;
141
+ return true ;
142
+ }
143
+ } ) ;
144
+ return resultsFromSuggestion ;
147
145
}
148
146
149
147
public Task InitAsync ( PluginInitContext context )
@@ -167,7 +165,9 @@ void Init()
167
165
// Custom images directory is in the WebSearch's data location folder
168
166
var name = Path . GetFileNameWithoutExtension ( _context . CurrentPluginMetadata . ExecuteFileName ) ;
169
167
CustomImagesDirectory = Path . Combine ( DataLocation . PluginSettingsDirectory , name , "CustomIcons" ) ;
170
- } ;
168
+ }
169
+
170
+ ;
171
171
}
172
172
173
173
#region ISettingProvider Members
@@ -191,4 +191,4 @@ public string GetTranslatedPluginDescription()
191
191
192
192
public event ResultUpdatedEventHandler ResultsUpdated ;
193
193
}
194
- }
194
+ }
0 commit comments