From 41087d88d46654f452566fa8bbf122282156dd67 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 25 Aug 2020 21:23:53 +1000 Subject: [PATCH 01/11] fix not triggering due to ActionKeyword is string empty when global --- .../Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 6c0d186f1..da2ae602b 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.FolderLinks; using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex; using Flow.Launcher.Plugin.SharedCommands; @@ -36,8 +36,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search var quickFolderLinks = quickFolderAccess.FolderList(query, settings.QuickFolderAccessLinks, context); - if (quickFolderLinks.Count > 0 && query.ActionKeyword == settings.SearchActionKeyword) - return quickFolderLinks; + var quickFolderLinks = quickFolderAccess.FolderListMatched(query, settings.QuickFolderAccessLinks, context); if (string.IsNullOrEmpty(querySearch)) return results; From e38b57d872fd25ce93d67ded330a3ffdc4456e69 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 25 Aug 2020 21:24:53 +1000 Subject: [PATCH 02/11] separate methods to better reflect responsibility --- .../Search/FolderLinks/QuickFolderAccess.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/QuickFolderAccess.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/QuickFolderAccess.cs index ebde039d6..8bd19956e 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/QuickFolderAccess.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/FolderLinks/QuickFolderAccess.cs @@ -6,14 +6,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search.FolderLinks { public class QuickFolderAccess { - internal List FolderList(Query query, List folderLinks, PluginInitContext context) + internal List FolderListMatched(Query query, List folderLinks, PluginInitContext context) { if (string.IsNullOrEmpty(query.Search)) - return folderLinks - .Select(item => - new ResultManager(context) - .CreateFolderResult(item.Nickname, item.Path, item.Path, query)) - .ToList(); + return new List(); string search = query.Search.ToLower(); @@ -24,5 +20,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search.FolderLinks .CreateFolderResult(item.Nickname, item.Path, item.Path, query)) .ToList(); } + + internal List FolderListAll(Query query, List folderLinks, PluginInitContext context) + => folderLinks + .Select(item => + new ResultManager(context).CreateFolderResult(item.Nickname, item.Path, item.Path, query)) + .ToList(); } } From 0a4f7c0c06c296d5759845e077fe8446baf8de33 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 25 Aug 2020 21:36:26 +1000 Subject: [PATCH 03/11] change QuickFolderAccess behaviour to continue with index search Even if QuickAccessFolders results matched still continue to do fIles and folders search before returning the results. This behaviour caters situation where user has a temp location in quick folder access list but still wants to search for temp folder in other locations --- .../Search/SearchManager.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index da2ae602b..bcac460f9 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -38,8 +38,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search var quickFolderLinks = quickFolderAccess.FolderListMatched(query, settings.QuickFolderAccessLinks, context); - if (string.IsNullOrEmpty(querySearch)) - return results; + if (quickFolderLinks.Count > 0) + results.AddRange(quickFolderLinks); if (IsFileContentSearch(query.ActionKeyword)) return WindowsIndexFileContentSearch(query, querySearch); @@ -53,7 +53,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search var isEnvironmentVariablePath = querySearch.Substring(1).Contains("%\\"); if (!FilesFolders.IsLocationPathString(querySearch) && !isEnvironmentVariablePath) - return WindowsIndexFilesAndFoldersSearch(query, querySearch); + { + results.AddRange(WindowsIndexFilesAndFoldersSearch(query, querySearch)); + + return results; + } var locationPath = querySearch; From 00035f7a52d958c625ed16d1575b394a03170dd1 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 25 Aug 2020 21:38:39 +1000 Subject: [PATCH 04/11] move contents search up --- Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index bcac460f9..95235a851 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -34,7 +34,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search var querySearch = query.Search; - var quickFolderLinks = quickFolderAccess.FolderList(query, settings.QuickFolderAccessLinks, context); + if (IsFileContentSearch(query.ActionKeyword)) + return WindowsIndexFileContentSearch(query, querySearch); var quickFolderLinks = quickFolderAccess.FolderListMatched(query, settings.QuickFolderAccessLinks, context); From c9c8d0065e63aa5faee507c5b4243f61050abd85 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 25 Aug 2020 21:40:17 +1000 Subject: [PATCH 05/11] make the code more obvious when triggering full quick folder access list --- .../Search/SearchManager.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 95235a851..bc6923173 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.FolderLinks; using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex; using Flow.Launcher.Plugin.SharedCommands; @@ -41,9 +41,12 @@ namespace Flow.Launcher.Plugin.Explorer.Search if (quickFolderLinks.Count > 0) results.AddRange(quickFolderLinks); - - if (IsFileContentSearch(query.ActionKeyword)) - return WindowsIndexFileContentSearch(query, querySearch); + + // This allows the user to type the assigned action keyword and only see the list of quick folder links + if (settings.QuickFolderAccessLinks.Count > 0 + && query.ActionKeyword == settings.SearchActionKeyword + && string.IsNullOrEmpty(query.Search)) + return quickFolderAccess.FolderListAll(query, settings.QuickFolderAccessLinks, context); var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch); From b2b98333d5099c52f5da2d697d77aa9600b73ed5 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 25 Aug 2020 21:46:44 +1000 Subject: [PATCH 06/11] version bump Explorer plugin --- Plugins/Flow.Launcher.Plugin.Explorer/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json b/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json index 67d2e731c..9695fd83d 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json @@ -7,7 +7,7 @@ "Name": "Explorer", "Description": "Search and manage files and folders. Explorer utilises Windows Index Search", "Author": "Jeremy Wu", - "Version": "1.2.2", + "Version": "1.2.3", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll", From 24fe5a11f98ec09b6f303df1718666d4d6610fbd Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Wed, 26 Aug 2020 08:06:10 +1000 Subject: [PATCH 07/11] prevent user from using global action keyword for content search would bring up too many results --- .../Flow.Launcher.Plugin.Explorer/Languages/en.xaml | 1 + .../ViewModels/SettingsViewModel.cs | 2 ++ .../Views/ActionKeywordSetting.xaml.cs | 11 ++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index b7710d332..2fb16e0e1 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -9,6 +9,7 @@ Are you sure you want to permanently delete this {0}? Deletion successful Successfully deleted the {0} + Assigning the global action keyword could bring up too many results during search. Please choose a specific action keyword Delete diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs index e14a6ebb5..7fcd77f07 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs @@ -54,5 +54,7 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels } internal bool IsActionKeywordAlreadyAssigned(string newActionKeyword) => PluginManager.ActionKeywordRegistered(newActionKeyword); + + internal bool IsNewActionKeywordGlobal(string newActionKeyword) => newActionKeyword == Query.GlobalPluginWildcardSign; } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs index b9e5373b7..2957283ad 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs @@ -51,8 +51,17 @@ namespace Flow.Launcher.Plugin.Explorer.Views return; } + + if (settingsViewModel.IsNewActionKeywordGlobal(newActionKeyword) + && currentActionKeyword.Description + == settingsViewModel.Context.API.GetTranslation("plugin_explorer_actionkeywordview_filecontentsearch")) + { + MessageBox.Show(settingsViewModel.Context.API.GetTranslation("plugin_explorer_globalActionKeywordInvalid")); + + return; + } - if(!settingsViewModel.IsActionKeywordAlreadyAssigned(newActionKeyword)) + if (!settingsViewModel.IsActionKeywordAlreadyAssigned(newActionKeyword)) { settingsViewModel.UpdateActionKeyword(newActionKeyword, currentActionKeyword.Keyword); From df5028ada9fcaf3b54f3580d1d7c7505a0fab47e Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Wed, 26 Aug 2020 08:06:51 +1000 Subject: [PATCH 08/11] move default content search action keyword string to constants --- Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs | 2 ++ Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs index db2eaa722..38939e244 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs @@ -22,6 +22,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search internal const char AllFilesFolderSearchWildcard = '>'; + internal const string DefaultContentSearchActionKeyword = "doc:"; + internal const char DirectorySeperator = '\\'; internal const string WindowsIndexingOptions = "srchadmin.dll"; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index 4e62b3cba..5b12870c8 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -1,4 +1,5 @@ -using Flow.Launcher.Plugin.Explorer.Search.FolderLinks; +using Flow.Launcher.Plugin.Explorer.Search; +using Flow.Launcher.Plugin.Explorer.Search.FolderLinks; using Newtonsoft.Json; using System.Collections.Generic; @@ -22,6 +23,6 @@ namespace Flow.Launcher.Plugin.Explorer public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign; [JsonProperty] - public string FileContentSearchActionKeyword { get; set; } = "doc:"; + public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword; } } \ No newline at end of file From 5661b20dfb7fca6ddeadb5ede48dfff07fef8416 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Wed, 26 Aug 2020 08:47:19 +1000 Subject: [PATCH 09/11] prevent index search when only '_' in query otherwise will throw OleDb error. --- .../Search/WindowsIndex/IndexSearch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs index 08511091e..187899c8f 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs @@ -21,7 +21,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex private readonly ResultManager resultManager; // Reserved keywords in oleDB - private readonly string reservedStringPattern = @"^[\/\\\$\%]+$"; + private readonly string reservedStringPattern = @"^[\/\\\$\%_]+$"; internal IndexSearch(PluginInitContext context) { From 0b368c26834d5e7eac09fbad60fb00e2c296526d Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Wed, 26 Aug 2020 14:10:39 +1000 Subject: [PATCH 10/11] fix file extension search using '*' failing --- .../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 bc6923173..6f44e8b57 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -144,15 +144,17 @@ namespace Flow.Launcher.Plugin.Explorer.Search private bool UseWindowsIndexForDirectorySearch(string locationPath) { + var pathToDirectory = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath); + if (!settings.UseWindowsIndexForDirectorySearch) return false; if (settings.IndexSearchExcludedSubdirectoryPaths - .Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(locationPath) + .Any(x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory) .StartsWith(x.Path, StringComparison.OrdinalIgnoreCase))) return false; - return indexSearch.PathIsIndexed(locationPath); + return indexSearch.PathIsIndexed(pathToDirectory); } } } From 2abbca17ef8665b98f97fc583422f7fd8ffa9b4c Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 21 Sep 2020 20:55:39 +1000 Subject: [PATCH 11/11] move Quick Folder Access list all method up move above matched Quick Folder Links because it's return type and will not run the remaining code --- .../Search/SearchManager.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 6f44e8b57..5b50b7fad 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -37,17 +37,17 @@ namespace Flow.Launcher.Plugin.Explorer.Search if (IsFileContentSearch(query.ActionKeyword)) return WindowsIndexFileContentSearch(query, querySearch); - var quickFolderLinks = quickFolderAccess.FolderListMatched(query, settings.QuickFolderAccessLinks, context); - - if (quickFolderLinks.Count > 0) - results.AddRange(quickFolderLinks); - // This allows the user to type the assigned action keyword and only see the list of quick folder links if (settings.QuickFolderAccessLinks.Count > 0 && query.ActionKeyword == settings.SearchActionKeyword && string.IsNullOrEmpty(query.Search)) return quickFolderAccess.FolderListAll(query, settings.QuickFolderAccessLinks, context); + var quickFolderLinks = quickFolderAccess.FolderListMatched(query, settings.QuickFolderAccessLinks, context); + + if (quickFolderLinks.Count > 0) + results.AddRange(quickFolderLinks); + var isEnvironmentVariable = EnvironmentVariables.IsEnvironmentVariableSearch(querySearch); if (isEnvironmentVariable)