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:
AT
2019-10-20 22:15:24 +03:00
parent a3ba2276e2
commit 8ee8f2c085
19 changed files with 149 additions and 26 deletions

View File

@@ -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);
}
}

View File

@@ -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 =>
{

View File

@@ -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 =>
{