@@ -41,8 +41,8 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
4141 var results = new List < Result > ( ) ;
4242
4343 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 ) )
4646 {
4747 string keyword = string . Empty ;
4848 keyword = searchSource . ActionKeyword == SearchSourceGlobalPluginWildCardSign ? query . ToString ( ) : query . Search ;
@@ -105,11 +105,11 @@ private async Task UpdateResultsFromSuggestionAsync(List<Result> results, string
105105 if ( _settings . EnableSuggestion )
106106 {
107107 var suggestions = await SuggestionsAsync ( keyword , subtitle , searchSource , token ) . ConfigureAwait ( false ) ;
108- if ( token . IsCancellationRequested || ! suggestions . Any ( ) )
108+ var enumerable = suggestions ? . ToList ( ) ;
109+ if ( token . IsCancellationRequested || enumerable is not { Count : > 0 } )
109110 return ;
110-
111-
112- results . AddRange ( suggestions ) ;
111+
112+ results . AddRange ( enumerable ) ;
113113
114114 token . ThrowIfCancellationRequested ( ) ;
115115 }
@@ -118,32 +118,32 @@ private async Task UpdateResultsFromSuggestionAsync(List<Result> results, string
118118 private async Task < IEnumerable < Result > > SuggestionsAsync ( string keyword , string subtitle , SearchSource searchSource , CancellationToken token )
119119 {
120120 var source = _settings . SelectedSuggestion ;
121- if ( source ! = null )
121+ if ( source = = null )
122122 {
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 ;
123+ return new List < Result > ( ) ;
124+ }
125+ //Suggestions appear below actual result, and appear above global action keyword match if non-global;
126+ var score = searchSource . ActionKeyword == SearchSourceGlobalPluginWildCardSign ? scoreSuggestions : scoreSuggestions + 1 ;
125127
126- var suggestions = await source . Suggestions ( keyword , token ) . ConfigureAwait ( false ) ;
128+ var suggestions = await source . SuggestionsAsync ( keyword , token ) . ConfigureAwait ( false ) ;
127129
128- token . ThrowIfCancellationRequested ( ) ;
130+ token . ThrowIfCancellationRequested ( ) ;
129131
130- var resultsFromSuggestion = suggestions ? . Select ( o => new Result
132+ var resultsFromSuggestion = suggestions ? . Select ( o => new Result
133+ {
134+ Title = o ,
135+ SubTitle = subtitle ,
136+ Score = score ,
137+ IcoPath = searchSource . IconPath ,
138+ ActionKeywordAssigned = searchSource . ActionKeyword == SearchSourceGlobalPluginWildCardSign ? string . Empty : searchSource . ActionKeyword ,
139+ Action = c =>
131140 {
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 ) ) ) ;
141+ _context . API . OpenUrl ( searchSource . Url . Replace ( "{q}" , Uri . EscapeDataString ( o ) ) ) ;
140142
141- return true ;
142- }
143- } ) ;
144- return resultsFromSuggestion ;
145- }
146- return new List < Result > ( ) ;
143+ return true ;
144+ }
145+ } ) ;
146+ return resultsFromSuggestion ;
147147 }
148148
149149 public Task InitAsync ( PluginInitContext context )
@@ -191,4 +191,4 @@ public string GetTranslatedPluginDescription()
191191
192192 public event ResultUpdatedEventHandler ResultsUpdated ;
193193 }
194- }
194+ }
0 commit comments