From 4965a72a2ebaa7ab376153929a8bc3a907f6b92f Mon Sep 17 00:00:00 2001 From: "Yu Leng (from Dev Box)" Date: Thu, 21 Aug 2025 14:41:48 +0800 Subject: [PATCH] init --- .../SettingsModel.cs | 2 ++ .../MatchLanguage.cs | 21 +++++++++++++++++++ .../MatchOption.cs | 2 ++ .../StringMatcher.cs | 10 +++++++++ 4 files changed, 35 insertions(+) create mode 100644 src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/MatchLanguage.cs diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs index b0d10a5285..35cafd11f0 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/SettingsModel.cs @@ -42,6 +42,8 @@ public partial class SettingsModel : ObservableObject public bool IgnoreShortcutWhenFullscreen { get; set; } + public bool IsePinYinInput { get; set; } = true; + public Dictionary ProviderSettings { get; set; } = []; public Dictionary Aliases { get; set; } = []; diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/MatchLanguage.cs b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/MatchLanguage.cs new file mode 100644 index 0000000000..b25b081590 --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/MatchLanguage.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Microsoft.CommandPalette.Extensions.Toolkit; + +public enum MatchLanguage +{ + English, + + // CJK will be matched by the CJK language pack + Chinese, + Japanese, + Korean, +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/MatchOption.cs b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/MatchOption.cs index 9f740e4ade..61dd0005d9 100644 --- a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/MatchOption.cs +++ b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/MatchOption.cs @@ -22,4 +22,6 @@ public partial class MatchOption public string Suffix { get; set; } = string.Empty; public bool IgnoreCase { get; set; } = true; + + public MatchLanguage Language { get; set; } = MatchLanguage.English; } diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/StringMatcher.cs b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/StringMatcher.cs index 6d9009661a..0f3bd8364f 100644 --- a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/StringMatcher.cs +++ b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/StringMatcher.cs @@ -38,6 +38,16 @@ public partial class StringMatcher return Instance.FuzzyMatch(query, stringToCompare); } + public static MatchResult FuzzySearch(string query, string stringToCompare, MatchLanguage language) + { + var opt = new MatchOption + { + Language = language, + }; + + return Instance.FuzzyMatch(query, stringToCompare, opt); + } + public MatchResult FuzzyMatch(string query, string stringToCompare) { try