[PTRun]Add Pinyin Support (#21465)

* Add Pinyin Support for Powertoys Run

using hyjiacan.pinyin4net

Revert microsoft/PowerToys#7455

closed microsoft/PowerToys#3587
closed microsoft/PowerToys#20370

Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>

* Remove JetBrains annotations

Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
This commit is contained in:
舰队的偶像-岛风酱!
2022-11-17 00:25:57 +08:00
committed by GitHub
parent 2f36366902
commit 28366fe5c4
8 changed files with 267 additions and 4 deletions

View File

@@ -20,6 +20,13 @@ namespace Wox.Infrastructure
public SearchPrecisionScore UserSettingSearchPrecision { get; set; }
private readonly IAlphabet _alphabet;
public StringMatcher(IAlphabet alphabet = null)
{
_alphabet = alphabet;
}
public static StringMatcher Instance { get; internal set; }
[Obsolete("This method is obsolete and should not be used. Please use the static function StringMatcher.FuzzySearch")]
@@ -90,6 +97,12 @@ namespace Wox.Infrastructure
query = query.Trim();
if (_alphabet != null)
{
query = _alphabet.Translate(query);
stringToCompare = _alphabet.Translate(stringToCompare);
}
// Using InvariantCulture since this is internal
var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToUpper(CultureInfo.InvariantCulture) : stringToCompare;
var queryWithoutCase = opt.IgnoreCase ? query.ToUpper(CultureInfo.InvariantCulture) : query;