mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-18 14:41:21 +08:00
Revert "Revert use FuzzyMatcher on Bookmarks since it's too slow"
This commit is contained in:
parent
b10caecbba
commit
53b19dad87
@ -22,7 +22,8 @@ namespace Wox.Plugin.System
|
||||
if (string.IsNullOrEmpty(query.RawQuery) || query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List<Result>();
|
||||
|
||||
var fuzzyMather = FuzzyMatcher.Create(query.RawQuery);
|
||||
List<Bookmark> returnList = bookmarks.Where(o => MatchProgram(o, query.RawQuery.ToLower())).ToList();
|
||||
List<Bookmark> returnList = bookmarks.Where(o => MatchProgram(o, fuzzyMather)).ToList();
|
||||
returnList = returnList.OrderByDescending(o => o.Score).ToList();
|
||||
return returnList.Select(c => new Result()
|
||||
{
|
||||
Title = c.Name,
|
||||
@ -37,11 +38,12 @@ namespace Wox.Plugin.System
|
||||
}
|
||||
}).ToList();
|
||||
}
|
||||
private bool MatchProgram(Bookmark bookmark, String query)
|
||||
private bool MatchProgram(Bookmark bookmark, FuzzyMatcher matcher)
|
||||
{
|
||||
if (bookmark.Name.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0) return true;
|
||||
if (bookmark.Url.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0) return true;
|
||||
if (bookmark.PinyinName.Contains(query)) return true;
|
||||
if ((bookmark.Score = matcher.Evaluate(bookmark.Name).Score) > 0) return true;
|
||||
if ((bookmark.Score = matcher.Evaluate(bookmark.PinyinName).Score) > 0) return true;
|
||||
if ((bookmark.Score = matcher.Evaluate(bookmark.Url).Score / 10) > 0) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -137,6 +139,7 @@ namespace Wox.Plugin.System
|
||||
public string PinyinName { get; private set; }
|
||||
public string Url { get; set; }
|
||||
public string Source { get; set; }
|
||||
public int Score { get; set; }
|
||||
|
||||
/* TODO: since Source maybe unimportant, we just need to compare Name and Url */
|
||||
public bool Equals(Bookmark other)
|
||||
|
Loading…
Reference in New Issue
Block a user