Skip to content

Commit 7749bbf

Browse files
Check environment variables
1 parent b8b6927 commit 7749bbf

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/Files.App/ViewModels/Settings/DevToolsViewModel.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Files Community
22
// Licensed under the MIT License.
33

4+
using System.IO;
45
using System.Windows.Input;
56

67
namespace Files.App.ViewModels.Settings
@@ -63,7 +64,8 @@ public string IDEPath
6364
IsIDEPathValid =
6465
!string.IsNullOrWhiteSpace(value) &&
6566
!value.Contains('\"') &&
66-
!value.Contains('\'');
67+
!value.Contains('\'') &&
68+
CheckPathExists();
6769
}
6870
}
6971
}
@@ -177,5 +179,20 @@ private async void DoTestIDE()
177179
PowerShellExecutionOptions.Hidden
178180
);
179181
}
182+
183+
private bool CheckPathExists()
184+
{
185+
if (Path.Exists(IDEPath))
186+
return true;
187+
188+
var paths = Environment.GetEnvironmentVariable("PATH")?.Split(';');
189+
foreach (var path in paths ?? Array.Empty<string>())
190+
{
191+
if (Path.Exists(Path.Combine(path, IDEPath)))
192+
return true;
193+
}
194+
195+
return false;
196+
}
180197
}
181198
}

0 commit comments

Comments
 (0)