From 617ef3b05d55317c9c25102618200d195b0b0ca0 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sat, 20 Jun 2020 14:26:13 +1000 Subject: [PATCH 1/2] fix environment variable search not showing up in Explorer --- .../Search/EnvironmentVariables.cs | 5 ++++- .../Search/SearchManager.cs | 20 +++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs index 5ba76bd7d..977b9423e 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs @@ -10,7 +10,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search { internal static bool IsEnvironmentVariableSearch(string search) { - return LoadEnvironmentStringPaths().Count > 0 && search.StartsWith("%") && !search.Substring(1).Contains("%"); + return LoadEnvironmentStringPaths().Count > 0 + && search.StartsWith("%") + && search != "%%" + && !search.Contains("\\"); } internal static Dictionary LoadEnvironmentStringPaths() diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 4d3f11967..eb4dceda4 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -39,19 +39,23 @@ namespace Flow.Launcher.Plugin.Explorer.Search if (quickFolderLinks.Count > 0) return quickFolderLinks; - if (string.IsNullOrEmpty(query.Search)) + if (string.IsNullOrEmpty(querySearch)) return results; - if (!FilesFolders.IsLocationPathString(querySearch)) - return WindowsIndexFilesAndFoldersSearch(query, querySearch); + var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch); - var locationPath = query.Search; - - if (EnvironmentVariables.IsEnvironmentVariableSearch(locationPath)) - return EnvironmentVariables.GetEnvironmentStringPathSuggestions(locationPath, query, context); + if (isEnvironmentVariable) + return EnvironmentVariables.GetEnvironmentStringPathSuggestions(querySearch, query, context); // Query is a location path with a full environment variable, eg. %appdata%\somefolder\ - if (locationPath.Substring(1).Contains("%")) + var isEnvironmentVariablePath = querySearch.Substring(1).Contains("%\\"); + + if (!FilesFolders.IsLocationPathString(querySearch) && !isEnvironmentVariable && !isEnvironmentVariablePath) + return WindowsIndexFilesAndFoldersSearch(query, querySearch); + + var locationPath = querySearch; + + if (isEnvironmentVariablePath) locationPath = EnvironmentVariables.TranslateEnvironmentVariablePath(locationPath); if (!FilesFolders.LocationExists(FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath))) From d47a1ed5a1d5209796e3b8d3ceb281bc1edfefb2 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 22 Jun 2020 05:02:42 +1000 Subject: [PATCH 2/2] remove unnecessary conditional variable in if- isEnvironmentVariable --- Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index eb4dceda4..f814962ba 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -50,7 +50,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search // Query is a location path with a full environment variable, eg. %appdata%\somefolder\ var isEnvironmentVariablePath = querySearch.Substring(1).Contains("%\\"); - if (!FilesFolders.IsLocationPathString(querySearch) && !isEnvironmentVariable && !isEnvironmentVariablePath) + if (!FilesFolders.IsLocationPathString(querySearch) && !isEnvironmentVariablePath) return WindowsIndexFilesAndFoldersSearch(query, querySearch); var locationPath = querySearch;