Skip to content

Commit a27d533

Browse files
committed
fix python plugin and node plugin
fix job process association the program plugin
1 parent 2370ec9 commit a27d533

File tree

5 files changed

+28
-29
lines changed

5 files changed

+28
-29
lines changed

Flow.Launcher.Core/Plugin/JsonRPCPluginV2.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ namespace Flow.Launcher.Core.Plugin
1515
{
1616
internal abstract class JsonRPCPluginV2 : JsonRPCPluginBase, IAsyncDisposable, IAsyncReloadable, IResultUpdated
1717
{
18-
public abstract string SupportedLanguage { get; set; }
19-
2018
public const string JsonRpc = "JsonRPC";
2119

2220
protected abstract IDuplexPipe ClientPipe { get; set; }

Flow.Launcher.Core/Plugin/NodePluginV2.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,13 @@ namespace Flow.Launcher.Core.Plugin
1010
/// <summary>
1111
/// Execution of JavaScript & TypeScript plugins
1212
/// </summary>
13-
internal class NodePluginV2 : ProcessStreamPluginV2
13+
internal sealed class NodePluginV2 : ProcessStreamPluginV2
1414
{
1515
public NodePluginV2(string filename)
1616
{
17-
StartInfo = new ProcessStartInfo
18-
{
19-
FileName = filename,
20-
UseShellExecute = false,
21-
CreateNoWindow = true,
22-
RedirectStandardOutput = true,
23-
RedirectStandardError = true
24-
};
17+
StartInfo = new ProcessStartInfo { FileName = filename, };
2518
}
2619

27-
public override string SupportedLanguage { get; set; }
2820
protected override ProcessStartInfo StartInfo { get; set; }
2921

3022
public override async Task InitAsync(PluginInitContext context)

Flow.Launcher.Core/Plugin/ProcessStreamPluginV2.cs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
using System;
1+
#nullable enable
2+
3+
using System;
24
using System.Collections.Generic;
35
using System.Diagnostics;
46
using System.IO.Pipelines;
57
using System.Threading.Tasks;
68
using Flow.Launcher.Infrastructure;
79
using Flow.Launcher.Plugin;
810
using Meziantou.Framework.Win32;
11+
using Microsoft.VisualBasic.ApplicationServices;
912
using Nerdbank.Streams;
1013

1114
namespace Flow.Launcher.Core.Plugin
@@ -18,31 +21,37 @@ static ProcessStreamPluginV2()
1821
{
1922
_jobObject.SetLimits(new JobObjectLimits()
2023
{
21-
Flags = JobObjectLimitFlags.KillOnJobClose | JobObjectLimitFlags.DieOnUnhandledException
24+
Flags = JobObjectLimitFlags.KillOnJobClose | JobObjectLimitFlags.DieOnUnhandledException |
25+
JobObjectLimitFlags.SilentBreakawayOk
2226
});
23-
27+
2428
_jobObject.AssignProcess(Process.GetCurrentProcess());
2529
}
2630

27-
public override string SupportedLanguage { get; set; }
28-
protected sealed override IDuplexPipe ClientPipe { get; set; }
31+
protected sealed override IDuplexPipe ClientPipe { get; set; } = null!;
2932

3033
protected abstract ProcessStartInfo StartInfo { get; set; }
3134

32-
protected Process ClientProcess { get; set; }
35+
protected Process ClientProcess { get; set; } = null!;
3336

3437
public override async Task InitAsync(PluginInitContext context)
3538
{
3639
StartInfo.EnvironmentVariables["FLOW_VERSION"] = Constant.Version;
3740
StartInfo.EnvironmentVariables["FLOW_PROGRAM_DIRECTORY"] = Constant.ProgramDirectory;
3841
StartInfo.EnvironmentVariables["FLOW_APPLICATION_DIRECTORY"] = Constant.ApplicationDirectory;
3942

40-
StartInfo.ArgumentList.Add(context.CurrentPluginMetadata.ExecuteFilePath);
43+
StartInfo.RedirectStandardError = true;
44+
StartInfo.RedirectStandardInput = true;
45+
StartInfo.RedirectStandardOutput = true;
46+
StartInfo.CreateNoWindow = true;
47+
StartInfo.UseShellExecute = false;
4148
StartInfo.WorkingDirectory = context.CurrentPluginMetadata.PluginDirectory;
4249

43-
ClientProcess = Process.Start(StartInfo);
44-
ArgumentNullException.ThrowIfNull(ClientProcess);
45-
50+
var process = Process.Start(StartInfo);
51+
ArgumentNullException.ThrowIfNull(process);
52+
ClientProcess = process;
53+
_jobObject.AssignProcess(ClientProcess);
54+
4655
SetupPipe(ClientProcess);
4756

4857
ErrorStream = ClientProcess.StandardError;

Flow.Launcher.Core/Plugin/PythonPluginV2.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,13 @@ namespace Flow.Launcher.Core.Plugin
1818
{
1919
internal sealed class PythonPluginV2 : ProcessStreamPluginV2
2020
{
21-
public override string SupportedLanguage { get; set; } = AllowedLanguage.Python;
2221
protected override ProcessStartInfo StartInfo { get; set; }
2322

2423
public PythonPluginV2(string filename)
2524
{
2625
StartInfo = new ProcessStartInfo
2726
{
2827
FileName = filename,
29-
UseShellExecute = false,
30-
CreateNoWindow = true,
31-
RedirectStandardOutput = true,
32-
RedirectStandardError = true,
33-
RedirectStandardInput = true
3428
};
3529

3630
var path = Path.Combine(Constant.ProgramDirectory, JsonRpc);
@@ -39,5 +33,11 @@ public PythonPluginV2(string filename)
3933
//Add -B flag to tell python don't write .py[co] files. Because .pyc contains location infos which will prevent python portable
4034
StartInfo.ArgumentList.Add("-B");
4135
}
36+
37+
public override async Task InitAsync(PluginInitContext context)
38+
{
39+
StartInfo.ArgumentList.Add(context.CurrentPluginMetadata.ExecuteFilePath);
40+
await base.InitAsync(context);
41+
}
4242
}
4343
}

Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public Result Result(string query, IPublicAPI api)
196196
FileName = FullPath,
197197
WorkingDirectory = ParentDirectory,
198198
UseShellExecute = true,
199-
Verb = runAsAdmin ? "runas" : ""
199+
Verb = runAsAdmin ? "runas" : "",
200200
};
201201

202202
_ = Task.Run(() => Main.StartProcess(Process.Start, info));

0 commit comments

Comments
 (0)