mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 05:05:00 +00:00
code_review!: PR #648
* rewrite `Models.ExternalTool` to use `_execArgsGenerator` instead of `OpenCmdArgs` and `ArgTransform` * remove dependency of `System.Linq` due to AOT limitations * since the `Visual Studio` is only available on Windows, use `TryAdd` directly. * update `README.md` BREAKING CHANGE: now the key in `external_editors.json` uses the same name with external tool. Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
1d0098703e
commit
6b348fbd1a
3 changed files with 59 additions and 59 deletions
|
@ -134,7 +134,7 @@ namespace SourceGit.Native
|
|||
finder.Fleet(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\Programs\\Fleet\\Fleet.exe");
|
||||
finder.FindJetBrainsFromToolbox(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\JetBrains\\Toolbox");
|
||||
finder.SublimeText(FindSublimeText);
|
||||
finder.VisualStudio(FindVisualStudio);
|
||||
finder.TryAdd("Visual Studio", "vs", FindVisualStudio, GenerateCommandlineArgsForVisualStudio);
|
||||
return finder.Founded;
|
||||
}
|
||||
|
||||
|
@ -325,7 +325,9 @@ namespace SourceGit.Native
|
|||
if (localMachine.OpenSubKey(@"SOFTWARE\Classes\VisualStudio.Launcher.sln\CLSID") is Microsoft.Win32.RegistryKey launcher)
|
||||
{
|
||||
// Get actual path to the executable
|
||||
if (launcher.GetValue(string.Empty) is string CLSID && localMachine.OpenSubKey(@$"SOFTWARE\Classes\CLSID\{CLSID}\LocalServer32") is Microsoft.Win32.RegistryKey devenv && devenv.GetValue(string.Empty) is string localServer32)
|
||||
if (launcher.GetValue(string.Empty) is string CLSID &&
|
||||
localMachine.OpenSubKey(@$"SOFTWARE\Classes\CLSID\{CLSID}\LocalServer32") is Microsoft.Win32.RegistryKey devenv &&
|
||||
devenv.GetValue(string.Empty) is string localServer32)
|
||||
{
|
||||
return localServer32!.Trim('\"');
|
||||
}
|
||||
|
@ -348,5 +350,31 @@ namespace SourceGit.Native
|
|||
ILFree(pidl);
|
||||
}
|
||||
}
|
||||
|
||||
private string GenerateCommandlineArgsForVisualStudio(string repo)
|
||||
{
|
||||
var sln = FindVSSolutionFile(repo, 4);
|
||||
return string.IsNullOrEmpty(sln) ? $"\"{repo}\"" : $"\"{sln}\"";
|
||||
}
|
||||
|
||||
private string FindVSSolutionFile(string path, int leftDepth)
|
||||
{
|
||||
var found = Directory.GetFiles(path, "*.sln", SearchOption.TopDirectoryOnly);
|
||||
if (found != null && found.Length > 0)
|
||||
return Path.GetFullPath(found[0]);
|
||||
|
||||
if (leftDepth <= 0)
|
||||
return null;
|
||||
|
||||
var subfolders = Directory.GetDirectories(path);
|
||||
foreach (var subfolder in subfolders)
|
||||
{
|
||||
var first = FindVSSolutionFile(subfolder, leftDepth - 1);
|
||||
if (!string.IsNullOrEmpty(first))
|
||||
return first;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue