mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
Merge pull request #85 from SysC0mp/highlight-how-results-matched
Highlight how results matched
This commit is contained in:
@@ -35,12 +35,10 @@ namespace Wox.Plugin.Program.Programs
|
||||
|
||||
private int Score(string query)
|
||||
{
|
||||
var score1 = StringMatcher.FuzzySearch(query, Name).ScoreAfterSearchPrecisionFilter();
|
||||
var score2 = StringMatcher.ScoreForPinyin(Name, query);
|
||||
var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter();
|
||||
var score4 = StringMatcher.ScoreForPinyin(Description, query);
|
||||
var score5 = StringMatcher.FuzzySearch(query, ExecutableName).ScoreAfterSearchPrecisionFilter();
|
||||
var score = new[] { score1, score2, score3, score4, score5 }.Max();
|
||||
var nameMatch = StringMatcher.FuzzySearch(query, Name);
|
||||
var descriptionMatch = StringMatcher.FuzzySearch(query, Description);
|
||||
var executableNameMatch = StringMatcher.FuzzySearch(query, ExecutableName);
|
||||
var score = new[] { nameMatch.Score, descriptionMatch.Score, executableNameMatch.Score }.Max();
|
||||
return score;
|
||||
}
|
||||
|
||||
@@ -75,14 +73,18 @@ namespace Wox.Plugin.Program.Programs
|
||||
Description.Substring(0, Name.Length) == Name)
|
||||
{
|
||||
result.Title = Description;
|
||||
result.TitleHighlightData = StringMatcher.FuzzySearch(query, Description).MatchData;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(Description))
|
||||
{
|
||||
result.Title = $"{Name}: {Description}";
|
||||
var title = $"{Name}: {Description}";
|
||||
result.Title = title;
|
||||
result.TitleHighlightData = StringMatcher.FuzzySearch(query, title).MatchData;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Title = Name;
|
||||
result.TitleHighlightData = StringMatcher.FuzzySearch(query, Name).MatchData;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user