mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
calculate score for addtional info
This commit is contained in:
@@ -87,18 +87,20 @@ namespace Wox.Plugin.ControlPanel
|
||||
|
||||
private int Score(ControlPanelItem item, string query)
|
||||
{
|
||||
var scores = new List<int>();
|
||||
if (item.LocalizedString != null)
|
||||
var scores = new List<int> {0};
|
||||
if (string.IsNullOrEmpty(item.LocalizedString))
|
||||
{
|
||||
var score1 = StringMatcher.Score(item.LocalizedString, query);
|
||||
var socre2 = StringMatcher.ScoreForPinyin(item.LocalizedString, query);
|
||||
scores.Add(Math.Max(score1, socre2));
|
||||
var score2 = StringMatcher.ScoreForPinyin(item.LocalizedString, query);
|
||||
scores.Add(score1);
|
||||
scores.Add(score2);
|
||||
}
|
||||
if (item.InfoTip != null)
|
||||
if (!string.IsNullOrEmpty(item.InfoTip))
|
||||
{
|
||||
// todo should we add pinyin score for infotip also?
|
||||
var score = StringMatcher.Score(item.InfoTip, query);
|
||||
scores.Add(score);
|
||||
var score1 = StringMatcher.Score(item.InfoTip, query);
|
||||
var score2 = StringMatcher.ScoreForPinyin(item.InfoTip, query);
|
||||
scores.Add(score1);
|
||||
scores.Add(score2);
|
||||
}
|
||||
return scores.Max();
|
||||
}
|
||||
|
||||
@@ -229,7 +229,8 @@ namespace Wox.Plugin.Program.Programs
|
||||
var score1 = StringMatcher.Score(DisplayName, query);
|
||||
var score2 = StringMatcher.ScoreForPinyin(DisplayName, query);
|
||||
var score3 = StringMatcher.Score(Description, query);
|
||||
var score = new[] { score1, score2, score3 }.Max();
|
||||
var score4= StringMatcher.ScoreForPinyin(Description, query);
|
||||
var score = new[] { score1, score2, score3, score4 }.Max();
|
||||
return score;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user