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
2 changes: 2 additions & 0 deletions Flow.Launcher.Core/Plugin/JsonPRCModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
using Flow.Launcher.Plugin;

namespace Flow.Launcher.Core.Plugin
Expand Down Expand Up @@ -42,6 +43,7 @@ public class JsonRPCResponseModel : JsonRPCModelBase

public class JsonRPCQueryResponseModel : JsonRPCResponseModel
{
[JsonPropertyName("result")]
public new List<JsonRPCResult> Result { get; set; }
}

Expand Down
65 changes: 30 additions & 35 deletions Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,47 +147,42 @@ protected string Execute(ProcessStartInfo startInfo)
{
try
{
using (var process = Process.Start(startInfo))
using var process = Process.Start(startInfo);
if (process == null)
{
if (process != null)
Log.Error("|JsonRPCPlugin.Execute|Can't start new process");
return string.Empty;
}

using var standardOutput = process.StandardOutput;
var result = standardOutput.ReadToEnd();
if (string.IsNullOrEmpty(result))
{
using (var standardError = process.StandardError)
{
using (var standardOutput = process.StandardOutput)
var error = standardError.ReadToEnd();
if (!string.IsNullOrEmpty(error))
{
var result = standardOutput.ReadToEnd();
if (string.IsNullOrEmpty(result))
{
using (var standardError = process.StandardError)
{
var error = standardError.ReadToEnd();
if (!string.IsNullOrEmpty(error))
{
Log.Error($"|JsonRPCPlugin.Execute|{error}");
return string.Empty;
}
else
{
Log.Error("|JsonRPCPlugin.Execute|Empty standard output and standard error.");
return string.Empty;
}
}
}
else if (result.StartsWith("DEBUG:"))
{
MessageBox.Show(new Form { TopMost = true }, result.Substring(6));
return string.Empty;
}
else
{
return result;
}
Log.Error($"|JsonRPCPlugin.Execute|{error}");
return string.Empty;
}
else
{
Log.Error("|JsonRPCPlugin.Execute|Empty standard output and standard error.");
return string.Empty;
}
}
else
{
Log.Error("|JsonRPCPlugin.Execute|Can't start new process");
return string.Empty;
}
}
else if (result.StartsWith("DEBUG:"))
{
MessageBox.Show(new Form { TopMost = true }, result.Substring(6));
return string.Empty;
}
else
{
return result;
}

}
catch (Exception e)
{
Expand Down
2 changes: 2 additions & 0 deletions Flow.Launcher.Core/Plugin/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ public static async Task<List<Result>> QueryForPlugin(PluginPair pair, Query que
throw new ArgumentOutOfRangeException();
}
token.ThrowIfCancellationRequested();
if (results == null)
return results;
UpdatePluginMetadata(results, metadata, query);

metadata.QueryCount += 1;
Expand Down
4 changes: 2 additions & 2 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ private void QueryContextMenu()
}

if (!match.IsSearchPrecisionScoreMet()) return false;

r.Score = match.Score;
return true;

Expand Down Expand Up @@ -512,7 +512,7 @@ async Task QueryTask(PluginPair plugin)
await Task.Yield();

var results = await PluginManager.QueryForPlugin(plugin, query, currentCancellationToken);
if (!currentCancellationToken.IsCancellationRequested)
if (!currentCancellationToken.IsCancellationRequested && results != null)
_resultsUpdateQueue.Post(new ResultsForUpdate(results, plugin.Metadata, query,
currentCancellationToken));
}
Expand Down