From 50b5336688e0e0041cd3ffa1f989b54414efdf7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=98=E9=9F=AC=20=E5=BC=A0?= Date: Tue, 13 Apr 2021 19:12:24 +0800 Subject: [PATCH 1/3] Allow Quick Access Links to be accessed with middle string, and score bump the result --- .../Search/QuickAccessLinks/QuickAccess.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/QuickAccess.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/QuickAccess.cs index d71e9ab49a8..f55d555e742 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/QuickAccess.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/QuickAccess.cs @@ -15,17 +15,24 @@ internal static List AccessLinkListMatched(Query query, List var queriedAccessLinks = accessLinks - .Where(x => x.Nickname.StartsWith(search, StringComparison.OrdinalIgnoreCase)) + .Where(x => x.Nickname.Contains(search, StringComparison.OrdinalIgnoreCase)) .OrderBy(x => x.Type) .ThenBy(x => x.Nickname); - return queriedAccessLinks.Select(l => l.Type switch + var matched = queriedAccessLinks.Select(l => l.Type switch { ResultType.Folder => ResultManager.CreateFolderResult(l.Nickname, l.Path, l.Path, query), ResultType.File => ResultManager.CreateFileResult(l.Path, query), _ => throw new ArgumentOutOfRangeException() }).ToList(); + + foreach (var r in matched) + { + r.Score = 100; + } + + return matched; } internal static List AccessLinkListAll(Query query, List accessLinks) From 1015177b45cb5527341f23e493681a904ac7bc62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=98=E9=9F=AC=20=E5=BC=A0?= Date: Tue, 13 Apr 2021 19:40:04 +0800 Subject: [PATCH 2/3] Refactor code --- .../Search/DirectoryInfo/DirectoryInfoSearch.cs | 4 ++-- .../Search/QuickAccessLinks/QuickAccess.cs | 15 ++++----------- .../Search/ResultManager.cs | 10 ++++++---- .../Search/WindowsIndex/IndexSearch.cs | 4 ++-- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs index acd960ef149..14833bae9b1 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs @@ -62,11 +62,11 @@ private static List DirectorySearch(EnumerationOptions enumerationOption if (fileSystemInfo is System.IO.DirectoryInfo) { folderList.Add(ResultManager.CreateFolderResult(fileSystemInfo.Name, fileSystemInfo.FullName, - fileSystemInfo.FullName, query, true, false)); + fileSystemInfo.FullName, query, 0, true, false)); } else { - fileList.Add(ResultManager.CreateFileResult(fileSystemInfo.FullName, query, true, false)); + fileList.Add(ResultManager.CreateFileResult(fileSystemInfo.FullName, query, 0, true, false)); } token.ThrowIfCancellationRequested(); diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/QuickAccess.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/QuickAccess.cs index f55d555e742..2dc09b55b91 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/QuickAccess.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/QuickAccessLinks/QuickAccess.cs @@ -19,20 +19,13 @@ internal static List AccessLinkListMatched(Query query, List .OrderBy(x => x.Type) .ThenBy(x => x.Nickname); - var matched = queriedAccessLinks.Select(l => l.Type switch + return queriedAccessLinks.Select(l => l.Type switch { - ResultType.Folder => ResultManager.CreateFolderResult(l.Nickname, l.Path, l.Path, query), - ResultType.File => ResultManager.CreateFileResult(l.Path, query), + ResultType.Folder => ResultManager.CreateFolderResult(l.Nickname, l.Path, l.Path, query, 100), + ResultType.File => ResultManager.CreateFileResult(l.Path, query, 100), _ => throw new ArgumentOutOfRangeException() }).ToList(); - - foreach (var r in matched) - { - r.Score = 100; - } - - return matched; } internal static List AccessLinkListAll(Query query, List accessLinks) @@ -42,7 +35,7 @@ internal static List AccessLinkListAll(Query query, List acc .Select(l => l.Type switch { ResultType.Folder => ResultManager.CreateFolderResult(l.Nickname, l.Path, l.Path, query), - ResultType.File => ResultManager.CreateFileResult(l.Path, query), + ResultType.File => ResultManager.CreateFileResult(l.Path, query, 100), _ => 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 6872f04b445..f756f8a0a7e 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -16,7 +16,7 @@ public static void Init(PluginInitContext context) Context = context; } - internal static Result CreateFolderResult(string title, string subtitle, string path, Query query, bool showIndexState = false, bool windowsIndexed = false) + internal static Result CreateFolderResult(string title, string subtitle, string path, Query query, int score = 0, bool showIndexState = false, bool windowsIndexed = false) { return new Result { @@ -46,6 +46,7 @@ internal static Result CreateFolderResult(string title, string subtitle, string query.ActionKeyword + " " + changeTo); return false; }, + Score = score, TitleToolTip = Constants.ToolTipOpenDirectory, SubTitleToolTip = Constants.ToolTipOpenDirectory, ContextData = new SearchResult { Type = ResultType.Folder, FullPath = path, ShowIndexState = showIndexState, WindowsIndexed = windowsIndexed } @@ -69,9 +70,9 @@ internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIn if (retrievedDirectoryPath != path) title = "Open " + folderName; - + var subtitleFolderName = folderName; - + // ie. max characters can be displayed without subtitle cutting off: "Program Files (x86)" if (folderName.Length > 19) subtitleFolderName = "the directory"; @@ -94,7 +95,7 @@ internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIn }; } - internal static Result CreateFileResult(string filePath, Query query, bool showIndexState = false, bool windowsIndexed = false) + internal static Result CreateFileResult(string filePath, Query query, int score = 0, bool showIndexState = false, bool windowsIndexed = false) { var result = new Result { @@ -102,6 +103,7 @@ internal static Result CreateFileResult(string filePath, Query query, bool showI SubTitle = filePath, IcoPath = filePath, TitleHighlightData = StringMatcher.FuzzySearch(query.Search, Path.GetFileName(filePath)).MatchData, + Score = score, Action = c => { try diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs index 22d89ba8fff..0748b0cfef6 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs @@ -53,11 +53,11 @@ internal async static Task> ExecuteWindowsIndexSearchAsync(string i dataReaderResults.GetString(0), path, path, - query, true, true)); + query, 0, true, true)); } else { - fileResults.Add(ResultManager.CreateFileResult(path, query, true, true)); + fileResults.Add(ResultManager.CreateFileResult(path, query, 0, true, true)); } } } From 750db306640eb22e808df644645fddb97c6dffff Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Wed, 14 Apr 2021 08:51:43 +1000 Subject: [PATCH 3/3] version bump Explorer plugin --- Plugins/Flow.Launcher.Plugin.Explorer/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json b/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json index 990ceadda22..e3b75219dfe 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Explorer/plugin.json @@ -7,7 +7,7 @@ "Name": "Explorer", "Description": "Search and manage files and folders. Explorer utilises Windows Index Search", "Author": "Jeremy Wu", - "Version": "1.7.2", + "Version": "1.7.3", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll",