mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +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)
|
private int Score(ControlPanelItem item, string query)
|
||||||
{
|
{
|
||||||
var scores = new List<int>();
|
var scores = new List<int> {0};
|
||||||
if (item.LocalizedString != null)
|
if (string.IsNullOrEmpty(item.LocalizedString))
|
||||||
{
|
{
|
||||||
var score1 = StringMatcher.Score(item.LocalizedString, query);
|
var score1 = StringMatcher.Score(item.LocalizedString, query);
|
||||||
var socre2 = StringMatcher.ScoreForPinyin(item.LocalizedString, query);
|
var score2 = StringMatcher.ScoreForPinyin(item.LocalizedString, query);
|
||||||
scores.Add(Math.Max(score1, socre2));
|
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 score1 = StringMatcher.Score(item.InfoTip, query);
|
||||||
var score = StringMatcher.Score(item.InfoTip, query);
|
var score2 = StringMatcher.ScoreForPinyin(item.InfoTip, query);
|
||||||
scores.Add(score);
|
scores.Add(score1);
|
||||||
|
scores.Add(score2);
|
||||||
}
|
}
|
||||||
return scores.Max();
|
return scores.Max();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -229,7 +229,8 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
var score1 = StringMatcher.Score(DisplayName, query);
|
var score1 = StringMatcher.Score(DisplayName, query);
|
||||||
var score2 = StringMatcher.ScoreForPinyin(DisplayName, query);
|
var score2 = StringMatcher.ScoreForPinyin(DisplayName, query);
|
||||||
var score3 = StringMatcher.Score(Description, 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;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user