feature: external editor supports visual studio code insiders; add environment variable VSCODE_PATH and FLEET_PATH to help to find these editors. (#54) (#55)

This commit is contained in:
leo 2024-04-03 12:17:20 +08:00
parent eea3d2c6c0
commit 0252887442
5 changed files with 79 additions and 12 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.IO;
using Avalonia;
@ -47,7 +48,12 @@ namespace SourceGit.Native
}
VSCodeExecutableFile = _backend.FindVSCode();
if (string.IsNullOrEmpty(VSCodeExecutableFile))
VSCodeExecutableFile = GetPathFromEnvironmentVar("VSCODE_PATH");
FleetExecutableFile = _backend.FindFleet();
if (string.IsNullOrEmpty(FleetExecutableFile))
FleetExecutableFile = GetPathFromEnvironmentVar("FLEET_PATH");
}
public static void SetupApp(AppBuilder builder)
@ -114,6 +120,17 @@ namespace SourceGit.Native
});
}
private static string GetPathFromEnvironmentVar(string key)
{
var customPath = Environment.GetEnvironmentVariable(key);
if (!string.IsNullOrEmpty(customPath) && File.Exists(customPath))
{
return customPath;
}
return string.Empty;
}
private static readonly IBackend _backend;
}
}