diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs index 28382020435..0d1d99f8a1b 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs @@ -17,7 +17,7 @@ public class Main : ISettingProvider, IAsyncPlugin, IContextMenu, IPluginI18n { internal static PluginInitContext Context { get; set; } - internal Settings Settings; + internal static Settings Settings { get; set; } private SettingsViewModel viewModel; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/QuickAccess.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/QuickAccess.cs index 85b595390cf..32651ecb8a7 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/QuickAccess.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/QuickAccess.cs @@ -6,7 +6,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks { internal static class QuickAccess { - private const int quickAccessResultScore = 100; + private const int QuickAccessResultScore = 100; internal static List AccessLinkListMatched(Query query, IEnumerable accessLinks) { @@ -19,8 +19,9 @@ internal static List AccessLinkListMatched(Query query, IEnumerable x.Name) .Select(l => l.Type switch { - ResultType.Folder => ResultManager.CreateFolderResult(l.Name, l.Path, l.Path, query, quickAccessResultScore), - ResultType.File => ResultManager.CreateFileResult(l.Path, query, quickAccessResultScore), + ResultType.Volume => ResultManager.CreateDriveSpaceDisplayResult(l.Path, query.ActionKeyword, QuickAccessResultScore), + ResultType.Folder => ResultManager.CreateFolderResult(l.Name, l.Path, l.Path, query, QuickAccessResultScore), + ResultType.File => ResultManager.CreateFileResult(l.Path, query, QuickAccessResultScore), _ => throw new ArgumentOutOfRangeException() }) .ToList(); @@ -32,8 +33,9 @@ internal static List AccessLinkListAll(Query query, IEnumerable x.Name) .Select(l => l.Type switch { - ResultType.Folder => ResultManager.CreateFolderResult(l.Name, l.Path, l.Path, query), - ResultType.File => ResultManager.CreateFileResult(l.Path, query, quickAccessResultScore), + ResultType.Volume => ResultManager.CreateDriveSpaceDisplayResult(l.Path, query.ActionKeyword, QuickAccessResultScore), + ResultType.Folder => ResultManager.CreateFolderResult(l.Name, l.Path, l.Path, query, QuickAccessResultScore), + ResultType.File => ResultManager.CreateFileResult(l.Path, query, QuickAccessResultScore), _ => throw new ArgumentOutOfRangeException() }).ToList(); } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index e87d2df9791..7791a98817c 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -171,7 +171,17 @@ internal static Result CreateFolderResult(string title, string subtitle, string }; } + internal static Result CreateDriveSpaceDisplayResult(string path, string actionKeyword, int score) + { + return CreateDriveSpaceDisplayResult(path, actionKeyword, score, SearchManager.UseIndexSearch(path)); + } + internal static Result CreateDriveSpaceDisplayResult(string path, string actionKeyword, bool windowsIndexed = false) + { + return CreateDriveSpaceDisplayResult(path, actionKeyword, 500, windowsIndexed); + } + + private static Result CreateDriveSpaceDisplayResult(string path, string actionKeyword, int score, bool windowsIndexed = false) { var progressBarColor = "#26a0da"; var title = string.Empty; // hide title when use progress bar, @@ -197,7 +207,7 @@ internal static Result CreateDriveSpaceDisplayResult(string path, string actionK SubTitle = subtitle, AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder, actionKeyword), IcoPath = path, - Score = 500, + Score = score, ProgressBar = progressValue, ProgressBarColor = progressBarColor, Preview = new Result.PreviewInfo diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 12df6c1458e..f4f87d4d4be 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -246,6 +246,18 @@ private async Task> PathSearchAsync(Query query, CancellationToken public bool IsFileContentSearch(string actionKeyword) => actionKeyword == Settings.FileContentSearchActionKeyword; + public static bool UseIndexSearch(string path) + { + if (Main.Settings.IndexSearchEngine is not Settings.IndexSearchEngineOption.WindowsIndex) + return false; + + // Check if the path is using windows index search + var pathToDirectory = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path); + + return !Main.Settings.IndexSearchExcludedSubdirectoryPaths.Any( + x => FilesFolders.ReturnPreviousDirectoryIfIncompleteString(pathToDirectory).StartsWith(x.Path, StringComparison.OrdinalIgnoreCase)) + && WindowsIndex.WindowsIndex.PathIsIndexed(pathToDirectory); + } private bool UseWindowsIndexForDirectorySearch(string locationPath) {