Skip to content

Commit

Permalink
Merge pull request Flow-Launcher#2415 from Flow-Launcher/fuzzy_search…
Browse files Browse the repository at this point in the history
…_access_links

Use FuzzySearch to search access links
  • Loading branch information
jjw24 authored Nov 14, 2023
2 parents f6f7af0 + 439eebf commit 57541b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,17 @@ internal static List<Result> AccessLinkListMatched(Query query, IEnumerable<Acce
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)
Expand Down
2 changes: 1 addition & 1 deletion Plugins/Flow.Launcher.Plugin.Explorer/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 57541b3

Please sign in to comment.