code_style: simpfy FindTerminal

* [macOS] should return `string.Empty` when failed to find terminal path
* [Linux] use `shell.Type` instead of `shell.Exec` to skip custom terminal detection
This commit is contained in:
leo 2024-09-18 15:19:24 +08:00
parent 9c6745c271
commit 69b39dac6c
No known key found for this signature in database
2 changed files with 3 additions and 12 deletions

View file

@ -26,19 +26,10 @@ namespace SourceGit.Native
public string FindTerminal(Models.ShellOrTerminal shell)
{
if (string.IsNullOrEmpty(shell.Exec))
if (shell.Type.Equals("custom", StringComparison.Ordinal))
return string.Empty;
var pathVariable = Environment.GetEnvironmentVariable("PATH") ?? string.Empty;
var pathes = pathVariable.Split(Path.PathSeparator, StringSplitOptions.RemoveEmptyEntries);
foreach (var path in pathes)
{
var test = Path.Combine(path, shell.Exec);
if (File.Exists(test))
return test;
}
return string.Empty;
return FindExecutable(shell.Exec);
}
public List<Models.ExternalTool> FindExternalTools()

View file

@ -34,7 +34,7 @@ namespace SourceGit.Native
return "iTerm";
}
return "InvalidTerminal";
return string.Empty;
}
public List<Models.ExternalTool> FindExternalTools()