Compare commits

...

21 commits

Author SHA1 Message Date
Jack Ye
940f5310bd
Merge 8e6d718144 into 10fcbb9990 2026-02-26 10:47:58 +08:00
Jack Ye
8e6d718144
Merge branch 'dev' into copilot/support-relative-paths 2026-02-26 10:47:56 +08:00
Jack251970
f756b71207 Catch all exceptions 2026-02-21 20:34:57 +08:00
Jack Ye
bfed5168f0
Improve code comments
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-21 20:32:41 +08:00
Jack251970
57fde0a2f3 Improve code comments 2026-02-21 20:30:54 +08:00
Jack251970
04a56b556b Use Path.IsPathFullyQualified for absolute path check
Replaced Path.IsPathRooted with Path.IsPathFullyQualified to more accurately determine if a path is truly absolute, preventing misclassification of certain relative paths.
2026-02-21 20:25:10 +08:00
Jack251970
d62fd05599 Ensure the path is updated in settings in case user has moved Flow to a different location 2026-02-21 20:22:04 +08:00
Jack251970
9b0a50376c Clarify exception type in path resolution catch block
Updated the catch block in DataLocation.cs to explicitly use System.Exception instead of Exception when handling path resolution errors. This improves code clarity while maintaining the same error handling logic for ArgumentException, NotSupportedException, and PathTooLongException.
2026-02-21 20:18:09 +08:00
Jack Ye
b923c40054
Merge branch 'dev' into copilot/support-relative-paths 2026-02-21 20:12:58 +08:00
Jack Ye
34a984cd86
Improve code comments
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-21 20:12:49 +08:00
Jack Ye
001101bb81
Improve error handling
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-21 20:11:49 +08:00
Jack251970
9fa4c37109 Remove relative path conversion for plugin settings files
Removed logic that converted absolute paths to relative paths within the ProgramDirectory. Now, plugin settings file paths are always stored as absolute paths. Deleted the ConvertToRelativePathIfPossible method and updated usages accordingly.
2026-01-24 16:07:04 +08:00
Jack251970
d49e5b4c1f Remove unused Flow.Launcher.Infrastructure using directive
Eliminated the unnecessary using statement for Flow.Launcher.Infrastructure in AbstractPluginEnvironment.cs, as its types or members are no longer referenced in this file. This helps clean up the code and avoid redundant dependencies.
2026-01-24 16:04:32 +08:00
Jack251970
d16e43de8a Refactor path utilities to DataLocation from Constant
Move ResolveAbsolutePath and ConvertToRelativePathIfPossible from Constant to DataLocation for better organization. Update all references accordingly; implementations remain unchanged. This improves code clarity around file path management.
2026-01-24 16:03:26 +08:00
Jack251970
9070ff4c7b Remove PathResolutionTest.cs and related path tests
Removed the PathResolutionTest.cs file, which contained unit tests for the Constant class's path resolution methods. These tests covered absolute, relative, UNC, null, and empty path scenarios, as well as round-trip conversions.
2026-01-24 15:58:37 +08:00
Jack251970
c59249d53a Save Python/Node paths as absolute, not relative
Removed logic that converted selected Python and Node executable
paths to relative if within the program directory. Now, the
selected file paths are stored as absolute paths without
conversion. This simplifies path handling and improves clarity.
2026-01-24 15:57:52 +08:00
Jack251970
ab5a0b493d Revert "Add UI descriptions for relative path support"
This reverts commit 864eedd255.
2026-01-24 15:55:49 +08:00
copilot-swe-agent[bot]
3de9e535ec Address code review feedback: convert absolute to relative paths for portability
Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
2026-01-24 07:51:22 +00:00
copilot-swe-agent[bot]
864eedd255 Add UI descriptions for relative path support
Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
2026-01-24 07:49:13 +00:00
copilot-swe-agent[bot]
d61ec1828f Add relative path resolution support for Python and Node.js executables
Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
2026-01-24 07:47:57 +00:00
copilot-swe-agent[bot]
438bb8a2fc Initial plan 2026-01-24 07:43:35 +00:00
2 changed files with 46 additions and 6 deletions

View file

@ -40,6 +40,12 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
PluginSettings = pluginSettings;
}
/// <summary>
/// Resolves the configured runtime executable path to an absolute path.
/// Supports both absolute paths and relative paths (relative to ProgramDirectory).
/// </summary>
private string ResolvedPluginsSettingsFilePath => DataLocation.ResolveAbsolutePath(PluginsSettingsFilePath);
internal IEnumerable<PluginPair> Setup()
{
// If no plugin is using the language, return empty list
@ -48,13 +54,16 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
return new List<PluginPair>();
}
if (!string.IsNullOrEmpty(PluginsSettingsFilePath) && FilesFolders.FileExists(PluginsSettingsFilePath))
var resolvedPath = ResolvedPluginsSettingsFilePath;
if (!string.IsNullOrEmpty(resolvedPath) && FilesFolders.FileExists(resolvedPath))
{
// Ensure latest only if user is using Flow's environment setup.
if (PluginsSettingsFilePath.StartsWith(EnvPath, StringComparison.OrdinalIgnoreCase))
EnsureLatestInstalled(ExecutablePath, PluginsSettingsFilePath, EnvPath);
if (resolvedPath.StartsWith(EnvPath, StringComparison.OrdinalIgnoreCase))
EnsureLatestInstalled(ExecutablePath, resolvedPath, EnvPath);
return SetPathForPluginPairs(PluginsSettingsFilePath, Language);
// Ensure the path is updated in settings in case environment was updated
resolvedPath = ResolvedPluginsSettingsFilePath;
return SetPathForPluginPairs(resolvedPath, Language);
}
var noRuntimeMessage = Localize.runtimePluginInstalledChooseRuntimePrompt(Language, EnvName, Environment.NewLine);
@ -103,9 +112,11 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
InstallEnvironment();
}
if (FilesFolders.FileExists(PluginsSettingsFilePath))
// Ensure the path is updated when user has chosen to install or select environment executable
resolvedPath = ResolvedPluginsSettingsFilePath;
if (FilesFolders.FileExists(resolvedPath))
{
return SetPathForPluginPairs(PluginsSettingsFilePath, Language);
return SetPathForPluginPairs(resolvedPath, Language);
}
else
{

View file

@ -42,5 +42,34 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public const string PluginEnvironments = "Environments";
public const string PluginDeleteFile = "NeedDelete.txt";
public static readonly string PluginEnvironmentsPath = Path.Combine(DataDirectory(), PluginEnvironments);
/// <summary>
/// Resolves a path that may be relative to an absolute path.
/// If the path is already absolute, returns it as-is.
/// If the path is not rooted (as determined by <see cref="Path.IsPathRooted(string)"/>), resolves it relative to ProgramDirectory.
/// </summary>
/// <param name="path">The path to resolve</param>
/// <returns>An absolute path</returns>
public static string ResolveAbsolutePath(string path)
{
if (string.IsNullOrEmpty(path))
return path;
// If already absolute, return as-is
if (Path.IsPathFullyQualified(path))
return path;
// Resolve relative to ProgramDirectory, handling invalid path formats gracefully
try
{
return Path.GetFullPath(Path.Combine(Constant.ProgramDirectory, path));
}
catch (System.Exception)
{
// If the path cannot be resolved (invalid characters, format, or too long),
// return the original path to avoid crashing the application.
return path;
}
}
}
}