Merge pull request #2415 from Flow-Launcher/fuzzy_search_access_links

Use FuzzySearch to search access links
This commit is contained in:
Jeremy Wu 2023-11-14 21:01:47 +11:00 committed by GitHub
commit 57541b351a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 14 deletions

View file

@ -13,20 +13,17 @@ namespace Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks
if (string.IsNullOrEmpty(query.Search))
return new List<Result>();
string search = query.Search.ToLower();
var queriedAccessLinks =
accessLinks
.Where(x => x.Name.Contains(search, StringComparison.OrdinalIgnoreCase) || x.Path.Contains(search, StringComparison.OrdinalIgnoreCase))
return accessLinks
.Where(x => Main.Context.API.FuzzySearch(query.Search, x.Name).IsSearchPrecisionScoreMet() || Main.Context.API.FuzzySearch(query.Search, x.Path).IsSearchPrecisionScoreMet())
.OrderBy(x => x.Type)
.ThenBy(x => x.Name);
return queriedAccessLinks.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),
_ => throw new ArgumentOutOfRangeException()
}).ToList();
.ThenBy(x => 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),
_ => throw new ArgumentOutOfRangeException()
})
.ToList();
}
internal static List<Result> AccessLinkListAll(Query query, IEnumerable<AccessLink> accessLinks)

View file

@ -10,7 +10,7 @@
"Name": "Explorer",
"Description": "Find and manage files and folders via Windows Search or Everything",
"Author": "Jeremy Wu",
"Version": "3.1.3",
"Version": "3.1.4",
"Language": "csharp",
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
"ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll",