diff --git a/src/Native/Windows.cs b/src/Native/Windows.cs index a0b5fbe0..1fdadb30 100644 --- a/src/Native/Windows.cs +++ b/src/Native/Windows.cs @@ -168,7 +168,14 @@ namespace SourceGit.Native startInfo.FileName = "cmd"; break; case Models.Shell.DefaultShellOfWindowsTerminal: - startInfo.FileName = "wt"; + var wt = FindWindowsTerminalApp(); + if (!File.Exists(wt)) + { + App.RaiseException(workdir, $"Can NOT found wt.exe on your system!"); + return; + } + + startInfo.FileName = FindWindowsTerminalApp(); break; default: App.RaiseException(workdir, $"Bad shell configuration!"); @@ -221,7 +228,8 @@ namespace SourceGit.Native // There's two version of PowerShell : pwsh.exe (preferred) and powershell.exe (system default) private string ChoosePowerShell() { - if (!string.IsNullOrEmpty(_powershellPath)) return _powershellPath; + if (!string.IsNullOrEmpty(_powershellPath)) + return _powershellPath; var localMachine = Microsoft.Win32.RegistryKey.OpenBaseKey( Microsoft.Win32.RegistryHive.LocalMachine, @@ -248,6 +256,21 @@ namespace SourceGit.Native return string.Empty; } + private string FindWindowsTerminalApp() + { + if (!string.IsNullOrEmpty(_wtPath)) + return _wtPath; + + var finder = new StringBuilder("wt.exe", 512); + if (PathFindOnPath(finder, null)) + { + _wtPath = finder.ToString(); + return _wtPath; + } + + return string.Empty; + } + #region EXTERNAL_EDITOR_FINDER private string FindVSCode() { @@ -342,5 +365,6 @@ namespace SourceGit.Native } private string _powershellPath = string.Empty; + private string _wtPath = string.Empty; } }