Results filter implementation

This commit is contained in:
Lasith Manujitha 2024-07-17 04:16:01 +05:30
parent 35bad615f3
commit b690123a19
2 changed files with 16 additions and 1 deletions

View file

@ -64,6 +64,8 @@
<system:String x:Key="plugin_explorer_Directory_Recursive_Search_Engine">Directory Recursive Search Engine</system:String>
<system:String x:Key="plugin_explorer_Index_Search_Engine">Index Search Engine</system:String>
<system:String x:Key="plugin_explorer_Open_Window_Index_Option">Open Windows Index Option</system:String>
<system:String x:Key="plugin_explorer_Excluded_File_Types">Ignored File Types (comma seperated)</system:String>
<system:String x:Key="plugin_explorer_Excluded_File_Types_Tooltip">For example: exe,jpg,png</system:String>
<!-- Plugin Infos -->
<system:String x:Key="plugin_explorer_plugin_name">Explorer</system:String>

View file

@ -8,6 +8,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Flow.Launcher.Plugin.Explorer.Exceptions;
using Path = System.IO.Path;
namespace Flow.Launcher.Plugin.Explorer.Search
{
@ -109,7 +110,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search
try
{
await foreach (var search in searchResults.WithCancellation(token).ConfigureAwait(false))
results.Add(ResultManager.CreateResult(query, search));
if (search.Type == ResultType.File && IsExcludedFile(search)) {
continue;
} else {
results.Add(ResultManager.CreateResult(query, search));
}
}
catch (OperationCanceledException)
{
@ -247,5 +252,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search
x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory).StartsWith(x.Path, StringComparison.OrdinalIgnoreCase))
&& WindowsIndex.WindowsIndex.PathIsIndexed(pathToDirectory);
}
private bool IsExcludedFile(SearchResult result)
{
string[] excludedFileTypes = Settings.ExcludedFileTypes.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
string fileExtension = Path.GetExtension(result.FullPath).TrimStart('.');
return excludedFileTypes.Contains(fileExtension);
}
}
}