Merge pull request #85 from SysC0mp/highlight-how-results-matched

Highlight how results matched
This commit is contained in:
Jeremy Wu
2019-12-12 07:24:22 +11:00
committed by GitHub
19 changed files with 324 additions and 123 deletions

View File

@@ -35,7 +35,6 @@ namespace Wox.Plugin.Program.Programs
public UWP(Package package)
{
Location = package.InstalledLocation.Path;
Name = package.Id.Name;
FullName = package.Id.FullName;
@@ -266,11 +265,9 @@ namespace Wox.Plugin.Program.Programs
private int Score(string query)
{
var score1 = StringMatcher.FuzzySearch(query, DisplayName).ScoreAfterSearchPrecisionFilter();
var score2 = StringMatcher.ScoreForPinyin(DisplayName, query);
var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter();
var score4 = StringMatcher.ScoreForPinyin(Description, query);
var score = new[] { score1, score2, score3, score4 }.Max();
var displayNameMatch = StringMatcher.FuzzySearch(query, DisplayName);
var descriptionMatch = StringMatcher.FuzzySearch(query, Description);
var score = new[] { displayNameMatch.Score, descriptionMatch.Score }.Max();
return score;
}
@@ -299,14 +296,18 @@ namespace Wox.Plugin.Program.Programs
Description.Substring(0, DisplayName.Length) == DisplayName)
{
result.Title = Description;
result.TitleHighlightData = StringMatcher.FuzzySearch(query, Description).MatchData;
}
else if (!string.IsNullOrEmpty(Description))
{
result.Title = $"{DisplayName}: {Description}";
var title = $"{DisplayName}: {Description}";
result.Title = title;
result.TitleHighlightData = StringMatcher.FuzzySearch(query, title).MatchData;
}
else
{
result.Title = DisplayName;
result.TitleHighlightData = StringMatcher.FuzzySearch(query, DisplayName).MatchData;
}
return result;
}