mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Results filter implementation
This commit is contained in:
parent
35bad615f3
commit
b690123a19
2 changed files with 16 additions and 1 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue