mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +02:00
added the abitliy to opt out of pinyin in control panel and in program plug in - this give a major perf boost (and I'm guessing it is not relevant for most users)
This commit is contained in:
@@ -9,6 +9,6 @@ namespace Wox.Plugin.Program.Programs
|
||||
public interface IProgram
|
||||
{
|
||||
List<Result> ContextMenus(IPublicAPI api);
|
||||
Result Result(string query, IPublicAPI api);
|
||||
Result Result(string query, IPublicAPI api, Settings settings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,23 +239,23 @@ namespace Wox.Plugin.Program.Programs
|
||||
public string LogoPath { get; set; }
|
||||
public UWP Package { get; set; }
|
||||
|
||||
private int Score(string query)
|
||||
private int Score(string query, bool shouldUsePinYin)
|
||||
{
|
||||
var score1 = StringMatcher.FuzzySearch(query, DisplayName).ScoreAfterSearchPrecisionFilter();
|
||||
var score2 = StringMatcher.ScoreForPinyin(DisplayName, query);
|
||||
var score2 = shouldUsePinYin ? StringMatcher.ScoreForPinyin(DisplayName, query) : 0;
|
||||
var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter();
|
||||
var score4 = StringMatcher.ScoreForPinyin(Description, query);
|
||||
var score4 = shouldUsePinYin ? StringMatcher.ScoreForPinyin(Description, query) : 0;
|
||||
var score = new[] { score1, score2, score3, score4 }.Max();
|
||||
return score;
|
||||
}
|
||||
|
||||
public Result Result(string query, IPublicAPI api)
|
||||
public Result Result(string query, IPublicAPI api, Settings settings)
|
||||
{
|
||||
var result = new Result
|
||||
{
|
||||
SubTitle = Package.Location,
|
||||
Icon = Logo,
|
||||
Score = Score(query),
|
||||
Score = Score(query, settings.ShouldUsePinYin),
|
||||
ContextData = this,
|
||||
Action = e =>
|
||||
{
|
||||
|
||||
@@ -29,25 +29,25 @@ namespace Wox.Plugin.Program.Programs
|
||||
private const string ApplicationReferenceExtension = "appref-ms";
|
||||
private const string ExeExtension = "exe";
|
||||
|
||||
private int Score(string query)
|
||||
private int Score(string query, bool shouldUsePinYin)
|
||||
{
|
||||
var score1 = StringMatcher.FuzzySearch(query, Name).ScoreAfterSearchPrecisionFilter();
|
||||
var score2 = StringMatcher.ScoreForPinyin(Name, query);
|
||||
var score2 = shouldUsePinYin ? StringMatcher.ScoreForPinyin(Name, query) : 0;
|
||||
var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter();
|
||||
var score4 = StringMatcher.ScoreForPinyin(Description, query);
|
||||
var score4 = shouldUsePinYin ? StringMatcher.ScoreForPinyin(Description, query) : 0;
|
||||
var score5 = StringMatcher.FuzzySearch(query, ExecutableName).ScoreAfterSearchPrecisionFilter();
|
||||
var score = new[] { score1, score2, score3, score4, score5 }.Max();
|
||||
return score;
|
||||
}
|
||||
|
||||
|
||||
public Result Result(string query, IPublicAPI api)
|
||||
public Result Result(string query, IPublicAPI api, Settings settings)
|
||||
{
|
||||
var result = new Result
|
||||
{
|
||||
SubTitle = FullPath,
|
||||
IcoPath = IcoPath,
|
||||
Score = Score(query),
|
||||
Score = Score(query, settings.ShouldUsePinYin),
|
||||
ContextData = this,
|
||||
Action = e =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user