Skip to content

Commit b690123

Browse files
committed
Results filter implementation
1 parent 35bad61 commit b690123

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
<system:String x:Key="plugin_explorer_Directory_Recursive_Search_Engine">Directory Recursive Search Engine</system:String>
6565
<system:String x:Key="plugin_explorer_Index_Search_Engine">Index Search Engine</system:String>
6666
<system:String x:Key="plugin_explorer_Open_Window_Index_Option">Open Windows Index Option</system:String>
67+
<system:String x:Key="plugin_explorer_Excluded_File_Types">Ignored File Types (comma seperated)</system:String>
68+
<system:String x:Key="plugin_explorer_Excluded_File_Types_Tooltip">For example: exe,jpg,png</system:String>
6769

6870
<!-- Plugin Infos -->
6971
<system:String x:Key="plugin_explorer_plugin_name">Explorer</system:String>

Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Threading;
99
using System.Threading.Tasks;
1010
using Flow.Launcher.Plugin.Explorer.Exceptions;
11+
using Path = System.IO.Path;
1112

1213
namespace Flow.Launcher.Plugin.Explorer.Search
1314
{
@@ -109,7 +110,11 @@ when ActionKeywordMatch(query, Settings.ActionKeyword.IndexSearchActionKeyword)
109110
try
110111
{
111112
await foreach (var search in searchResults.WithCancellation(token).ConfigureAwait(false))
112-
results.Add(ResultManager.CreateResult(query, search));
113+
if (search.Type == ResultType.File && IsExcludedFile(search)) {
114+
continue;
115+
} else {
116+
results.Add(ResultManager.CreateResult(query, search));
117+
}
113118
}
114119
catch (OperationCanceledException)
115120
{
@@ -247,5 +252,13 @@ private bool UseWindowsIndexForDirectorySearch(string locationPath)
247252
x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory).StartsWith(x.Path, StringComparison.OrdinalIgnoreCase))
248253
&& WindowsIndex.WindowsIndex.PathIsIndexed(pathToDirectory);
249254
}
255+
256+
private bool IsExcludedFile(SearchResult result)
257+
{
258+
string[] excludedFileTypes = Settings.ExcludedFileTypes.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
259+
string fileExtension = Path.GetExtension(result.FullPath).TrimStart('.');
260+
261+
return excludedFileTypes.Contains(fileExtension);
262+
}
250263
}
251264
}

0 commit comments

Comments
 (0)