From 69b39dac6c5ba257ddc904a8b17d45129a3aca94 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 18 Sep 2024 15:19:24 +0800 Subject: [PATCH] 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 --- src/Native/Linux.cs | 13 ++----------- src/Native/MacOS.cs | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/Native/Linux.cs b/src/Native/Linux.cs index 7c3f20f8..f784c691 100644 --- a/src/Native/Linux.cs +++ b/src/Native/Linux.cs @@ -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 FindExternalTools() diff --git a/src/Native/MacOS.cs b/src/Native/MacOS.cs index 81918284..6e2293a7 100644 --- a/src/Native/MacOS.cs +++ b/src/Native/MacOS.cs @@ -34,7 +34,7 @@ namespace SourceGit.Native return "iTerm"; } - return "InvalidTerminal"; + return string.Empty; } public List FindExternalTools()