diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index 60a15ca3392..18fc336758c 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -64,6 +64,8 @@ Directory Recursive Search Engine Index Search Engine Open Windows Index Option + Excluded File Types (comma seperated) + For example: exe,jpg,png Explorer diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index f53623ac0c3..8fd1674765f 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -8,6 +8,7 @@ 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 @@ when ActionKeywordMatch(query, Settings.ActionKeyword.IndexSearchActionKeyword) 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 @@ private bool UseWindowsIndexForDirectorySearch(string locationPath) 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, StringComparer.OrdinalIgnoreCase); + } } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index 8a7daf5859d..3d30bcf29e5 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -25,6 +25,8 @@ public class Settings public string ShellPath { get; set; } = "cmd"; + public string ExcludedFileTypes { get; set; } = ""; + public bool UseLocationAsWorkingDir { get; set; } = false; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs index 4185104607c..729e05ba0f4 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs @@ -513,6 +513,18 @@ public string ShellPath } } + public string ExcludedFileTypes + { + get => Settings.ExcludedFileTypes; + set + { + // remove spaces and dots from the string before saving + string sanitized = string.IsNullOrEmpty(value) ? "" : value.Replace(" ", "").Replace(".", ""); + Settings.ExcludedFileTypes = sanitized; + OnPropertyChanged(); + } + } + #region Everything FastSortWarning diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml index 59d8efc7321..caad341c80b 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml @@ -281,6 +281,7 @@ + + +