mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-18 14:41:21 +08:00
Pass "ShouldUsePinyin" to StringMatcher
Flag is used in method "ShouldUsePinyin()" to avoid calling Alphabet service. Otherwise, tests applying to StringMatcher.FuzzySearch() would fail because the pinyin helper library fails to initialize.
This commit is contained in:
parent
78f243651e
commit
49c5c5bbde
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -13,6 +13,7 @@ namespace Wox.Infrastructure
|
||||
public static MatchOption DefaultMatchOption = new MatchOption();
|
||||
|
||||
public static string UserSettingSearchPrecision { get; set; }
|
||||
public static bool ShouldUsePinyin { get; set; }
|
||||
|
||||
[Obsolete("This method is obsolete and should not be used. Please use the static function StringMatcher.FuzzySearch")]
|
||||
public static int Score(string source, string target)
|
||||
@ -135,6 +136,11 @@ namespace Wox.Infrastructure
|
||||
|
||||
public static int ScoreForPinyin(string source, string target)
|
||||
{
|
||||
if (!ShouldUsePinyin)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(target))
|
||||
{
|
||||
if (Alphabet.ContainsChinese(source))
|
||||
|
@ -24,7 +24,17 @@ namespace Wox.Infrastructure.UserSettings
|
||||
/// <summary>
|
||||
/// when false Alphabet static service will always return empty results
|
||||
/// </summary>
|
||||
public bool ShouldUsePinyin { get; set; } = true;
|
||||
private bool _shouldUsePinyin = true;
|
||||
public bool ShouldUsePinyin
|
||||
{
|
||||
get { return _shouldUsePinyin; }
|
||||
set
|
||||
{
|
||||
_shouldUsePinyin = value;
|
||||
StringMatcher.ShouldUsePinyin = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private string _querySearchPrecision { get; set; } = StringMatcher.SearchPrecisionScore.Regular.ToString();
|
||||
public string QuerySearchPrecision
|
||||
|
@ -56,6 +56,7 @@ namespace Wox
|
||||
Alphabet.Initialize(_settings);
|
||||
|
||||
StringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision;
|
||||
StringMatcher.ShouldUsePinyin = _settings.ShouldUsePinyin;
|
||||
|
||||
PluginManager.LoadPlugins(_settings.PluginSettings);
|
||||
_mainVM = new MainViewModel(_settings);
|
||||
|
Loading…
Reference in New Issue
Block a user