From a318bcb80eed58a9e52a94fed382b8695f06d386 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sat, 13 Jul 2024 22:15:50 +1000 Subject: [PATCH 1/3] fix condition not triggering path search when path is part env variable --- .../Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 5fe01d3a5..9593a5a52 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -1,4 +1,4 @@ -using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo; +using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo; using Flow.Launcher.Plugin.Explorer.Search.Everything; using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks; using Flow.Launcher.Plugin.SharedCommands; @@ -68,7 +68,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search IAsyncEnumerable searchResults; - bool isPathSearch = query.Search.IsLocationPathString() || IsEnvironmentVariableSearch(query.Search); + bool isPathSearch = query.Search.IsLocationPathString() + || EnvironmentVariables.IsEnvironmentVariableSearch(query.Search) + || EnvironmentVariables.HasEnvironmentVar(query.Search); string engineName; From 67ae8e579e5560a0616f910db6d0f00838732bb2 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sat, 13 Jul 2024 22:16:45 +1000 Subject: [PATCH 2/3] remove duplicate env variable check method --- .../Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 9593a5a52..0f9d888c3 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -247,12 +247,5 @@ namespace Flow.Launcher.Plugin.Explorer.Search x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory).StartsWith(x.Path, StringComparison.OrdinalIgnoreCase)) && WindowsIndex.WindowsIndex.PathIsIndexed(pathToDirectory); } - - internal static bool IsEnvironmentVariableSearch(string search) - { - return search.StartsWith("%") - && search != "%%" - && !search.Contains('\\'); - } } } From 4b78926a77a387694f08bcd2f57e38adf03984b1 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sat, 13 Jul 2024 22:17:56 +1000 Subject: [PATCH 3/3] use actual path variable consistently throughout path search --- .../Search/SearchManager.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 0f9d888c3..f53623ac0 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -1,4 +1,4 @@ -using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo; +using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo; using Flow.Launcher.Plugin.Explorer.Search.Everything; using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks; using Flow.Launcher.Plugin.SharedCommands; @@ -180,16 +180,16 @@ namespace Flow.Launcher.Plugin.Explorer.Search // Query is a location path with a full environment variable, eg. %appdata%\somefolder\, c:\users\%USERNAME%\downloads var needToExpand = EnvironmentVariables.HasEnvironmentVar(querySearch); - var locationPath = needToExpand ? Environment.ExpandEnvironmentVariables(querySearch) : querySearch; + var path = needToExpand ? Environment.ExpandEnvironmentVariables(querySearch) : querySearch; // Check that actual location exists, otherwise directory search will throw directory not found exception - if (!FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath).LocationExists()) + if (!FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path).LocationExists()) return results.ToList(); var useIndexSearch = Settings.IndexSearchEngine is Settings.IndexSearchEngineOption.WindowsIndex - && UseWindowsIndexForDirectorySearch(locationPath); + && UseWindowsIndexForDirectorySearch(path); - var retrievedDirectoryPath = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath); + var retrievedDirectoryPath = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path); results.Add(retrievedDirectoryPath.EndsWith(":\\") ? ResultManager.CreateDriveSpaceDisplayResult(retrievedDirectoryPath, query.ActionKeyword, useIndexSearch) @@ -200,21 +200,21 @@ namespace Flow.Launcher.Plugin.Explorer.Search IAsyncEnumerable directoryResult; - var recursiveIndicatorIndex = query.Search.IndexOf('>'); + var recursiveIndicatorIndex = path.IndexOf('>'); if (recursiveIndicatorIndex > 0 && Settings.PathEnumerationEngine != Settings.PathEnumerationEngineOption.DirectEnumeration) { directoryResult = Settings.PathEnumerator.EnumerateAsync( - query.Search[..recursiveIndicatorIndex].Trim(), - query.Search[(recursiveIndicatorIndex + 1)..], + path[..recursiveIndicatorIndex].Trim(), + path[(recursiveIndicatorIndex + 1)..], true, token); } else { - directoryResult = DirectoryInfoSearch.TopLevelDirectorySearch(query, query.Search, token).ToAsyncEnumerable(); + directoryResult = DirectoryInfoSearch.TopLevelDirectorySearch(query, path, token).ToAsyncEnumerable(); } if (token.IsCancellationRequested)