Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Flow.Launcher.Core/Plugin/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ public static async Task<List<Result>> QueryForPlugin(PluginPair pair, Query que
catch (OperationCanceledException)
{
// null will be fine since the results will only be added into queue if the token hasn't been cancelled
return results = null;
return null;
}
catch (Exception e)
{
Log.Exception($"|PluginManager.QueryForPlugin|Exception for plugin <{pair.Metadata.Name}> when query <{query}>", e);
Log.Exception($"|PluginManager.QueryForPlugin|Exception for plugin <{pair.Metadata.Name}> when query <{query}>", e);
}

return results;
Expand Down
4 changes: 2 additions & 2 deletions Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ private async Task<IEnumerable<Result>> SuggestionsAsync(string keyword, string
var source = _settings.SelectedSuggestion;
if (source != null)
{
var suggestions = await source.Suggestions(keyword, token);
var suggestions = await source.Suggestions(keyword, token).ConfigureAwait(false);

if (token.IsCancellationRequested)
return null;

var resultsFromSuggestion = suggestions.Select(o => new Result
var resultsFromSuggestion = suggestions?.Select(o => new Result
{
Title = o,
SubTitle = subtitle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override async Task<List<string>> Suggestions(string query, CancellationT
catch (HttpRequestException e)
{
Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e);
return new List<string>();
return null;
}

if (string.IsNullOrEmpty(result)) return new List<string>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@ public override async Task<List<string>> Suggestions(string query, CancellationT
const string api = "https://api.bing.com/qsonhs.aspx?q=";

using var resultStream = await Http.GetStreamAsync(api + Uri.EscapeUriString(query), token).ConfigureAwait(false);

if (resultStream.Length == 0)
return new List<string>(); // this handles the cancellation


json = (await JsonDocument.ParseAsync(resultStream, cancellationToken: token)).RootElement.GetProperty("AS");

}
catch (TaskCanceledException)
{
return null;
return new List<string>();
}
catch (HttpRequestException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@ public override async Task<List<string>> Suggestions(string query, CancellationT

using var resultStream = await Http.GetStreamAsync(api + Uri.EscapeUriString(query)).ConfigureAwait(false);

if (resultStream.Length == 0)
return new List<string>();

json = await JsonDocument.ParseAsync(resultStream);

}
catch (TaskCanceledException)
{
return null;
return new List<string>();
}
catch (HttpRequestException e)
{
Expand Down