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