mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 20:24:59 +00:00
code_review: PR #480
* remove `string.IsNullOrEmpty(OS.ShellOrTerminal)` checking from detail backend since it has been checked by `Native.OS.OpenTerminal` * remove `ViewModels.Preference.IsTerminalConfigured` because it is only used by itself (Unlike `IsGitConfigured`). * add `Native.OS.TestShellOrTerminal` and use it instead of setting `Preference.ShellOrTerminal` directly, because we have binded a callback that will save preference into file when its property changed. It may cause lag in some enviroments if we saving preference into file too frequently (see PR #436). * run `dotnet format`
This commit is contained in:
parent
65c2087f6b
commit
bc633e4085
5 changed files with 44 additions and 61 deletions
|
@ -27,9 +27,7 @@ namespace SourceGit.Native
|
|||
public string FindTerminal(Models.ShellOrTerminal shell)
|
||||
{
|
||||
if (string.IsNullOrEmpty(shell.Exec))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var pathVariable = Environment.GetEnvironmentVariable("PATH") ?? string.Empty;
|
||||
var pathes = pathVariable.Split(Path.PathSeparator, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
@ -76,23 +74,18 @@ namespace SourceGit.Native
|
|||
|
||||
public void OpenTerminal(string workdir)
|
||||
{
|
||||
if (string.IsNullOrEmpty(OS.ShellOrTerminal))
|
||||
{
|
||||
App.RaiseException(workdir, $"Terminal is not specified! Please confirm that the correct shell/terminal has been configured.");
|
||||
return;
|
||||
}
|
||||
|
||||
var startInfo = new ProcessStartInfo();
|
||||
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||
startInfo.WorkingDirectory = string.IsNullOrEmpty(workdir) ? home : workdir;
|
||||
startInfo.FileName = OS.ShellOrTerminal;
|
||||
|
||||
try
|
||||
{
|
||||
Process.Start(startInfo);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
App.RaiseException(workdir, e.Message);
|
||||
App.RaiseException(workdir, $"Failed to start '{OS.ShellOrTerminal}'. Reason: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue