diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index 134c3c002dc..cc8bfdc6b31 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -151,6 +151,22 @@ public static async Task InitializePlugins(IPublicAPI api) NonGlobalPlugins[actionKeyword] = plugin; break; } + + + + + + + if (plugin.Metadata.Name == "Explorer") + { + NonGlobalPlugins["d"] = plugin; + NonGlobalPlugins["f"] = plugin; + } + + + + + } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 2aa389f8950..8885165bc9b 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using System.Text.RegularExpressions; namespace Flow.Launcher.Plugin.Explorer.Search { @@ -41,6 +42,49 @@ public int GetHashCode(Result obj) internal async Task> SearchAsync(Query query, CancellationToken token) { var querySearch = query.Search; + + + + + + if ((query.ActionKeyword == "d" || query.ActionKeyword == "f") && querySearch.Length > 0) + { + var queryConstructor = new QueryConstructor(settings); + + var connectionString = queryConstructor.CreateQueryHelper().ConnectionString; + var reservedStringPattern = @"^[`\@\#\^,\&\/\\\$\%_]+$"; + + + var regexMatch = Regex.Match(querySearch, reservedStringPattern); + + if (regexMatch.Success) + return new List(); + + var constructedQuery = $@"SELECT TOP 100 + System.FileName, + System.ItemUrl, + System.ItemType, + System.Search.Rank + FROM SystemIndex + WHERE scope='file:' + AND CONTAINS(System.FileName,'""{querySearch}*""', 2057)"; + if (query.ActionKeyword == "d") + { + constructedQuery += " AND System.ItemType = 'Directory' "; + } else if (query.ActionKeyword == "f") + { + constructedQuery += " AND NOT System.ItemType = 'Directory' "; + } + constructedQuery += " ORDER BY System.Search.Rank DESC "; + + return await IndexSearch.ExecuteWindowsIndexSearchAsync(constructedQuery, connectionString, query, token) + .ConfigureAwait(false); + } + + + + + if (IsFileContentSearch(query.ActionKeyword)) return await WindowsIndexFileContentSearchAsync(query, querySearch, token).ConfigureAwait(false);