diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index d5f882d5c..e9b4b0fc1 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -109,6 +109,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search return await IndexSearch.WindowsIndexSearchAsync(querySearchString, queryConstructor.CreateQueryHelper().ConnectionString, queryConstructor.QueryForFileContentSearch, + settings.IndexSearchExcludedSubdirectoryPaths, query, token).ConfigureAwait(false); } @@ -144,6 +145,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search return await IndexSearch.WindowsIndexSearchAsync(querySearchString, queryConstructor.CreateQueryHelper().ConnectionString, queryConstructor.QueryForAllFilesAndFolders, + settings.IndexSearchExcludedSubdirectoryPaths, query, token).ConfigureAwait(false); } @@ -155,6 +157,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search return await IndexSearch.WindowsIndexSearchAsync(path, queryConstructor.CreateQueryHelper().ConnectionString, queryConstructor.QueryForTopLevelDirectorySearch, + settings.IndexSearchExcludedSubdirectoryPaths, query, token).ConfigureAwait(false); } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs index b1e1d7622..ecadd61ec 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs @@ -1,4 +1,5 @@ using Flow.Launcher.Infrastructure.Logger; +using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks; using Microsoft.Search.Interop; using System; using System.Collections.Generic; @@ -83,7 +84,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex } internal async static Task> WindowsIndexSearchAsync(string searchString, string connectionString, - Func constructQuery, Query query, + Func constructQuery, + List exclusionList, + Query query, CancellationToken token) { var regexMatch = Regex.Match(searchString, reservedStringPattern); @@ -92,8 +95,41 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex return new List(); var constructedQuery = constructQuery(searchString); - return await ExecuteWindowsIndexSearchAsync(constructedQuery, connectionString, query, token); + return await RemoveResultsInExclusionList( + await ExecuteWindowsIndexSearchAsync(constructedQuery, connectionString, query, token), + exclusionList); + } + private async static Task> RemoveResultsInExclusionList(List results, List exclusionList) + { + var indexExclusionListCount = exclusionList.Count; + + if (indexExclusionListCount == 0) + return results; + + var filteredResults = new List(); + + await Task.Run(() => + { + for (var index = 0; index < results.Count; index++) + { + var excludeResult = false; + + for (var i = 0; i < indexExclusionListCount; i++) + { + if (results[index].SubTitle.StartsWith(exclusionList[i].Path, StringComparison.OrdinalIgnoreCase)) + { + excludeResult = true; + break; + } + } + + if (!excludeResult) + filteredResults.Add(results[index]); + } + }); + + return filteredResults; } internal static bool PathIsIndexed(string path) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json b/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json index 63ca66a1e..990ceadda 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.7.1", + "Version": "1.7.2", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll",