From a3cc5e25f9e8cad6cde6a7360a10da2400589f10 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Fri, 7 Feb 2025 16:05:35 +0800 Subject: [PATCH 1/3] Fix unix directory seperator issue --- Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs | 2 ++ .../Search/DirectoryInfo/DirectoryInfoSearch.cs | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs index e7b43c555f6..bc1fb8e7a91 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs @@ -31,6 +31,8 @@ internal static class Constants internal const string DefaultContentSearchActionKeyword = "doc:"; + internal const char UnixDirectorySeparator = '/'; + internal const char DirectorySeparator = '\\'; internal const string WindowsIndexingOptions = "srchadmin.dll"; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs index 9fd495f4910..e3e1c62e698 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs @@ -1,4 +1,4 @@ -using Flow.Launcher.Infrastructure.Logger; +using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Plugin.SharedCommands; using System; using System.Collections.Generic; @@ -12,6 +12,9 @@ public static class DirectoryInfoSearch { internal static IEnumerable TopLevelDirectorySearch(Query query, string search, CancellationToken token) { + // if user uses the unix directory separator, we need to convert it to windows directory separator + search = search.Replace(Constants.UnixDirectorySeparator, Constants.DirectorySeparator); + var criteria = ConstructSearchCriteria(search); if (search.LastIndexOf(Constants.AllFilesFolderSearchWildcard) > From 3ee3528e5433c6da1f6f1c37095e92c8ec9153ba Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Fri, 7 Feb 2025 16:40:45 +0800 Subject: [PATCH 2/3] Revert "Fix unix directory seperator issue" This reverts commit a3cc5e25f9e8cad6cde6a7360a10da2400589f10. --- Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs | 2 -- .../Search/DirectoryInfo/DirectoryInfoSearch.cs | 5 +---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs index bc1fb8e7a91..e7b43c555f6 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs @@ -31,8 +31,6 @@ internal static class Constants internal const string DefaultContentSearchActionKeyword = "doc:"; - internal const char UnixDirectorySeparator = '/'; - internal const char DirectorySeparator = '\\'; internal const string WindowsIndexingOptions = "srchadmin.dll"; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs index e3e1c62e698..9fd495f4910 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs @@ -1,4 +1,4 @@ -using Flow.Launcher.Infrastructure.Logger; +using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Plugin.SharedCommands; using System; using System.Collections.Generic; @@ -12,9 +12,6 @@ public static class DirectoryInfoSearch { internal static IEnumerable TopLevelDirectorySearch(Query query, string search, CancellationToken token) { - // if user uses the unix directory separator, we need to convert it to windows directory separator - search = search.Replace(Constants.UnixDirectorySeparator, Constants.DirectorySeparator); - var criteria = ConstructSearchCriteria(search); if (search.LastIndexOf(Constants.AllFilesFolderSearchWildcard) > From 5ee110b3b741b310bfebffc4edbf5b371c0f5db4 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Fri, 7 Feb 2025 16:42:01 +0800 Subject: [PATCH 3/3] Fix unix directory seperator issue --- Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs | 3 ++- Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs index e7b43c555f6..4bddfd9b27d 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs @@ -22,7 +22,6 @@ internal static class Constants internal const string WindowsIndexErrorImagePath = "Images\\index_error2.png"; internal const string GeneralSearchErrorImagePath = "Images\\robot_error.png"; - internal const string ToolTipOpenDirectory = "Ctrl + Enter to open the directory"; internal const string ToolTipOpenContainingFolder = "Ctrl + Enter to open the containing folder"; @@ -31,6 +30,8 @@ internal static class Constants internal const string DefaultContentSearchActionKeyword = "doc:"; + internal const char UnixDirectorySeparator = '/'; + internal const char DirectorySeparator = '\\'; internal const string WindowsIndexingOptions = "srchadmin.dll"; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 8fd1674765f..12df6c1458e 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -187,6 +187,9 @@ private async Task> PathSearchAsync(Query query, CancellationToken var needToExpand = EnvironmentVariables.HasEnvironmentVar(querySearch); var path = needToExpand ? Environment.ExpandEnvironmentVariables(querySearch) : querySearch; + // if user uses the unix directory separator, we need to convert it to windows directory separator + path = path.Replace(Constants.UnixDirectorySeparator, Constants.DirectorySeparator); + // Check that actual location exists, otherwise directory search will throw directory not found exception if (!FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path).LocationExists()) return results.ToList();