From 434ba827057f5aa7ad6c9342aa8bb52877fc8619 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sun, 17 Nov 2019 18:06:25 +1100 Subject: [PATCH 01/17] Fix build fail from task reindex run --- Plugins/Wox.Plugin.Program/Main.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Wox.Plugin.Program/Main.cs b/Plugins/Wox.Plugin.Program/Main.cs index 009dd84fbd..e165a10826 100644 --- a/Plugins/Wox.Plugin.Program/Main.cs +++ b/Plugins/Wox.Plugin.Program/Main.cs @@ -111,9 +111,9 @@ namespace Wox.Plugin.Program public static void IndexPrograms() { - var t1 = Task.Run(IndexWin32Programs); + var t1 = Task.Run(()=>IndexWin32Programs()); - var t2 = Task.Run(IndexUWPPrograms); + var t2 = Task.Run(()=>IndexUWPPrograms()); Task.WaitAll(t1, t2); From 05f66f9bead5e5c4eb7cad070d2eb06efcc742a7 Mon Sep 17 00:00:00 2001 From: SysC0mp Date: Thu, 28 Nov 2019 12:44:01 +0100 Subject: [PATCH 02/17] Improve code formatting --- Wox.Infrastructure/StringMatcher.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Wox.Infrastructure/StringMatcher.cs b/Wox.Infrastructure/StringMatcher.cs index 5b82b18918..8d66e19c21 100644 --- a/Wox.Infrastructure/StringMatcher.cs +++ b/Wox.Infrastructure/StringMatcher.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Text; using Wox.Infrastructure.Logger; @@ -95,14 +95,20 @@ namespace Wox.Infrastructure private static int CalScore(string query, string stringToCompare, int firstIndex, int matchLen) { - //a match found near the beginning of a string is scored more than a match found near the end - //a match is scored more if the characters in the patterns are closer to each other, while the score is lower if they are more spread out + // A match found near the beginning of a string is scored more than a match found near the end + // A match is scored more if the characters in the patterns are closer to each other, + // while the score is lower if they are more spread out var score = 100 * (query.Length + 1) / ((1 + firstIndex) + (matchLen + 1)); - //a match with less characters assigning more weights + + // A match with less characters assigning more weights if (stringToCompare.Length - query.Length < 5) + { score += 20; + } else if (stringToCompare.Length - query.Length < 10) + { score += 10; + } return score; } From 3d55ad783eda0b9b2624b833d87f259bf401c9a6 Mon Sep 17 00:00:00 2001 From: SysC0mp Date: Tue, 3 Dec 2019 14:55:22 +0100 Subject: [PATCH 03/17] Only pass needed setting to Alphabet As Alphabet class is static, its methods could be used without ever calling Alphabet.initialize(_settings) beforehand which would end in an exception. Therefor only _shouldUsePinyin settings needed will be transferred with a given default value. --- Wox.Infrastructure/Alphabet.cs | 74 +++++++++++++++++++--------------- Wox/App.xaml.cs | 4 +- 2 files changed, 44 insertions(+), 34 deletions(-) diff --git a/Wox.Infrastructure/Alphabet.cs b/Wox.Infrastructure/Alphabet.cs index d7fae882cb..a2f64241a4 100644 --- a/Wox.Infrastructure/Alphabet.cs +++ b/Wox.Infrastructure/Alphabet.cs @@ -15,17 +15,26 @@ namespace Wox.Infrastructure private static readonly HanyuPinyinOutputFormat Format = new HanyuPinyinOutputFormat(); private static ConcurrentDictionary PinyinCache; private static BinaryStorage> _pinyinStorage; - private static Settings _settings; - - public static void Initialize(Settings settings) + private static bool _shouldUsePinyin = true; + + public static void Initialize(bool shouldUsePinyin = true) + { + _shouldUsePinyin = shouldUsePinyin; + if (_shouldUsePinyin) + { + InitializePinyinHelpers(); + } + } + + private static void InitializePinyinHelpers() { - _settings = settings; Format.setToneType(HanyuPinyinToneType.WITHOUT_TONE); Stopwatch.Normal("|Wox.Infrastructure.Alphabet.Initialize|Preload pinyin cache", () => { _pinyinStorage = new BinaryStorage>("Pinyin"); PinyinCache = _pinyinStorage.TryLoad(new ConcurrentDictionary()); + // force pinyin library static constructor initialize PinyinHelper.toHanyuPinyinStringArray('T', Format); }); @@ -34,6 +43,10 @@ namespace Wox.Infrastructure public static void Save() { + if (!_shouldUsePinyin) + { + return; + } _pinyinStorage.Save(PinyinCache); } @@ -46,7 +59,7 @@ namespace Wox.Infrastructure /// public static string[] Pinyin(string word) { - if (!_settings.ShouldUsePinyin) + if (!_shouldUsePinyin) { return EmptyStringArray; } @@ -68,39 +81,36 @@ namespace Wox.Infrastructure /// public static string[][] PinyinComination(string characters) { - if (_settings.ShouldUsePinyin && !string.IsNullOrEmpty(characters)) + if (!_shouldUsePinyin || string.IsNullOrEmpty(characters)) { - if (!PinyinCache.ContainsKey(characters)) - { + return Empty2DStringArray; + } - var allPinyins = new List(); - foreach (var c in characters) + if (!PinyinCache.ContainsKey(characters)) + { + var allPinyins = new List(); + foreach (var c in characters) + { + var pinyins = PinyinHelper.toHanyuPinyinStringArray(c, Format); + if (pinyins != null) { - var pinyins = PinyinHelper.toHanyuPinyinStringArray(c, Format); - if (pinyins != null) - { - var r = pinyins.Distinct().ToArray(); - allPinyins.Add(r); - } - else - { - var r = new[] { c.ToString() }; - allPinyins.Add(r); - } + var r = pinyins.Distinct().ToArray(); + allPinyins.Add(r); } + else + { + var r = new[] { c.ToString() }; + allPinyins.Add(r); + } + } - var combination = allPinyins.Aggregate(Combination).Select(c => c.Split(';')).ToArray(); - PinyinCache[characters] = combination; - return combination; - } - else - { - return PinyinCache[characters]; - } + var combination = allPinyins.Aggregate(Combination).Select(c => c.Split(';')).ToArray(); + PinyinCache[characters] = combination; + return combination; } else { - return Empty2DStringArray; + return PinyinCache[characters]; } } @@ -112,7 +122,7 @@ namespace Wox.Infrastructure public static bool ContainsChinese(string word) { - if (!_settings.ShouldUsePinyin) + if (!_shouldUsePinyin) { return false; } @@ -130,7 +140,7 @@ namespace Wox.Infrastructure private static string[] Combination(string[] array1, string[] array2) { - if (!_settings.ShouldUsePinyin) + if (!_shouldUsePinyin) { return EmptyStringArray; } diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index 0ec1614bf9..acfb88d266 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics; using System.Threading.Tasks; using System.Timers; @@ -53,7 +53,7 @@ namespace Wox _settingsVM = new SettingWindowViewModel(); _settings = _settingsVM.Settings; - Alphabet.Initialize(_settings); + Alphabet.Initialize(_settings.ShouldUsePinyin); StringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision; From 6ebca7fa7cf0462d9ff9734f216d7ef460fef16d Mon Sep 17 00:00:00 2001 From: SysC0mp Date: Tue, 3 Dec 2019 14:58:52 +0100 Subject: [PATCH 04/17] Apply search precision filter on assignment The search precision must be used, so it makes sense to apply the filter directly on score assignment. Score will be "0" if precision filter was not met. --- Wox.Infrastructure/StringMatcher.cs | 49 +++++++++++++++++++---------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/Wox.Infrastructure/StringMatcher.cs b/Wox.Infrastructure/StringMatcher.cs index 8d66e19c21..d24bdf2c35 100644 --- a/Wox.Infrastructure/StringMatcher.cs +++ b/Wox.Infrastructure/StringMatcher.cs @@ -120,19 +120,6 @@ namespace Wox.Infrastructure None = 0 } - public static bool IsSearchPrecisionScoreMet(this MatchResult matchResult) - { - var precisionScore = (SearchPrecisionScore)Enum.Parse(typeof(SearchPrecisionScore), - UserSettingSearchPrecision ?? SearchPrecisionScore.Regular.ToString()); - return matchResult.Score >= (int)precisionScore; - } - - public static int ScoreAfterSearchPrecisionFilter(this MatchResult matchResult) - { - return matchResult.IsSearchPrecisionScoreMet() ? matchResult.Score : 0; - - } - public static int ScoreForPinyin(string source, string target) { if (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(target)) @@ -164,12 +151,42 @@ namespace Wox.Infrastructure public class MatchResult { public bool Success { get; set; } - public int Score { get; set; } + + private int _score; + public int Score + { + get + { + return _score; + } + set + { + _score = ApplySearchPrecisionFilter(value); + } + } /// - /// highlight string + /// Matched data to highlight. /// - public string Value { get; set; } + public List MatchData { get; set; } + + public bool IsSearchPrecisionScoreMet() + { + return IsSearchPrecisionScoreMet(Score); + } + + private bool IsSearchPrecisionScoreMet(int score) + { + var precisionScore = (SearchPrecisionScore)Enum.Parse( + typeof(SearchPrecisionScore), + UserSettingSearchPrecision ?? SearchPrecisionScore.Regular.ToString()); + return score >= (int)precisionScore; + } + + private int ApplySearchPrecisionFilter(int score) + { + return IsSearchPrecisionScoreMet(score) ? score : 0; + } } public class MatchOption From 627e99859d76ee624062e96e3e76ddb308288910 Mon Sep 17 00:00:00 2001 From: SysC0mp Date: Tue, 3 Dec 2019 15:02:59 +0100 Subject: [PATCH 05/17] Directly calculate pinyin if needed The MatchResult will always get the maximum score from either ScoreForPinyin() or CalculateSearchScore(). ScoreForPinyin() is completely dependant on the "ShouldUsePinyin" global setting. --- Wox.Infrastructure/StringMatcher.cs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Wox.Infrastructure/StringMatcher.cs b/Wox.Infrastructure/StringMatcher.cs index d24bdf2c35..dd5a118fb4 100644 --- a/Wox.Infrastructure/StringMatcher.cs +++ b/Wox.Infrastructure/StringMatcher.cs @@ -1,10 +1,12 @@ -using System; +using System; +using System.Collections.Generic; using System.Linq; using System.Text; using Wox.Infrastructure.Logger; using Wox.Infrastructure.UserSettings; +using static Wox.Infrastructure.StringMatcher; -namespace Wox.Infrastructure +namespace Wox.Infrastructure { public static class StringMatcher { @@ -54,6 +56,9 @@ namespace Wox.Infrastructure var firstMatchIndex = -1; var lastMatchIndex = 0; char ch; + + var indexList = new List(); + for (var idx = 0; idx < len; idx++) { ch = stringToCompare[idx]; @@ -63,6 +68,7 @@ namespace Wox.Infrastructure firstMatchIndex = idx; lastMatchIndex = idx + 1; + indexList.Add(idx); sb.Append(opt.Prefix + ch + opt.Suffix); patternIdx += 1; } @@ -82,18 +88,25 @@ namespace Wox.Infrastructure // return rendered string if we have a match for every char if (patternIdx == pattern.Length) { - return new MatchResult + var score = CalculateSearchScore(query, stringToCompare, firstMatchIndex, lastMatchIndex - firstMatchIndex); + var pinyinScore = ScoreForPinyin(stringToCompare, query); + + var result = new MatchResult { Success = true, - Value = sb.ToString(), - Score = CalScore(query, stringToCompare, firstMatchIndex, lastMatchIndex - firstMatchIndex) + MatchData = indexList, + Score = Math.Max(score, pinyinScore) }; + + return result.Score > 0 ? + result : + new MatchResult { Success = false }; } return new MatchResult { Success = false }; } - private static int CalScore(string query, string stringToCompare, int firstIndex, int matchLen) + private static int CalculateSearchScore(string query, string stringToCompare, int firstIndex, int matchLen) { // A match found near the beginning of a string is scored more than a match found near the end // A match is scored more if the characters in the patterns are closer to each other, @@ -164,7 +177,7 @@ namespace Wox.Infrastructure _score = ApplySearchPrecisionFilter(value); } } - + /// /// Matched data to highlight. /// From 2aeceb7ea8e305fed8567240a45c738b944e4ce1 Mon Sep 17 00:00:00 2001 From: SysC0mp Date: Tue, 3 Dec 2019 15:04:02 +0100 Subject: [PATCH 06/17] Fix tests for new search precision handling --- Wox.Test/FuzzyMatcherTest.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Wox.Test/FuzzyMatcherTest.cs b/Wox.Test/FuzzyMatcherTest.cs index ce1746a3a3..aa8778a54c 100644 --- a/Wox.Test/FuzzyMatcherTest.cs +++ b/Wox.Test/FuzzyMatcherTest.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.Linq; using NUnit.Framework; using Wox.Infrastructure; +using Wox.Infrastructure.UserSettings; using Wox.Plugin; namespace Wox.Test @@ -48,6 +49,8 @@ namespace Wox.Test "aac" }; + Alphabet.Initialize(false); + StringMatcher.UserSettingSearchPrecision = StringMatcher.SearchPrecisionScore.Low.ToString(); var results = new List(); foreach (var str in sources) @@ -130,6 +133,9 @@ namespace Wox.Test var results = new List(); + Alphabet.Initialize(false); + StringMatcher.UserSettingSearchPrecision = StringMatcher.SearchPrecisionScore.None.ToString(); + foreach (var str in searchStrings) { results.Add(new Result @@ -168,8 +174,11 @@ namespace Wox.Test [TestCase("ccs", "Candy Crush Saga from King", (int)StringMatcher.SearchPrecisionScore.Low, true)] [TestCase("cand", "Candy Crush Saga from King", (int)StringMatcher.SearchPrecisionScore.Regular, true)] [TestCase("cand", "Help cure hope raise on mind entity Chrome", (int)StringMatcher.SearchPrecisionScore.Regular, false)] - public void WhenGivenDesiredPrecisionThenShouldReturnAllResultsGreaterOrEqual(string queryString, string compareString, - int expectedPrecisionScore, bool expectedPrecisionResult) + public void WhenGivenDesiredPrecisionThenShouldReturnAllResultsGreaterOrEqual( + string queryString, + string compareString, + int expectedPrecisionScore, + bool expectedPrecisionResult) { var expectedPrecisionString = (StringMatcher.SearchPrecisionScore)expectedPrecisionScore; StringMatcher.UserSettingSearchPrecision = expectedPrecisionString.ToString(); From 8997c27819e514027a5410f18c32353ebc5c90a8 Mon Sep 17 00:00:00 2001 From: SysC0mp Date: Tue, 3 Dec 2019 15:08:21 +0100 Subject: [PATCH 07/17] Add highlight converter component --- Wox/Converters/HighlightTextConverter.cs | 53 ++++++++++++++++++++++++ Wox/ResultListBox.xaml | 22 +++++++++- Wox/ViewModel/RelayCommand.cs | 1 - Wox/ViewModel/ResultsViewModel.cs | 31 ++++++++++++++ Wox/Wox.csproj | 1 + 5 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 Wox/Converters/HighlightTextConverter.cs diff --git a/Wox/Converters/HighlightTextConverter.cs b/Wox/Converters/HighlightTextConverter.cs new file mode 100644 index 0000000000..b7d6d06838 --- /dev/null +++ b/Wox/Converters/HighlightTextConverter.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; +using System.Windows.Documents; + +namespace Wox.Converters +{ + public class HighlightTextConverter : IMultiValueConverter + { + public object Convert(object[] value, Type targetType, object parameter, CultureInfo cultureInfo) + { + var text = value[0] as string; + var highlightData = value[1] as List; + + var textBlock = new Span(); + + if (highlightData == null || !highlightData.Any()) + { + // No highlight data, just return the text + return new Run(text); + } + + for (var i = 0; i < text.Length; i++) + { + var currentCharacter = text.Substring(i, 1); + if (this.ShouldHighlight(highlightData, i)) + { + textBlock.Inlines.Add(new Bold(new Run(currentCharacter))); + } + else + { + textBlock.Inlines.Add(new Run(currentCharacter)); + } + } + return textBlock; + } + + public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture) + { + return new[] { DependencyProperty.UnsetValue, DependencyProperty.UnsetValue }; + } + + private bool ShouldHighlight(List highlightData, int index) + { + return highlightData.Contains(index); + } + } +} diff --git a/Wox/ResultListBox.xaml b/Wox/ResultListBox.xaml index cad02d5198..dc3100e0e7 100644 --- a/Wox/ResultListBox.xaml +++ b/Wox/ResultListBox.xaml @@ -4,6 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:vm="clr-namespace:Wox.ViewModel" + xmlns:converter="clr-namespace:Wox.Converters" mc:Ignorable="d" d:DesignWidth="100" d:DesignHeight="100" d:DataContext="{d:DesignInstance vm:ResultsViewModel}" MaxHeight="{Binding MaxHeight}" @@ -30,6 +31,9 @@ + + + @@ -44,9 +48,23 @@ + Text="{Binding Result.Title}"> + + + + + + + + Grid.Row="1" x:Name="SubTitle" Text="{Binding Result.SubTitle}"> + + + + + + + diff --git a/Wox/ViewModel/RelayCommand.cs b/Wox/ViewModel/RelayCommand.cs index 3a52f30007..b1dbc551c1 100644 --- a/Wox/ViewModel/RelayCommand.cs +++ b/Wox/ViewModel/RelayCommand.cs @@ -5,7 +5,6 @@ namespace Wox.ViewModel { public class RelayCommand : ICommand { - private Action _action; public RelayCommand(Action action) diff --git a/Wox/ViewModel/ResultsViewModel.cs b/Wox/ViewModel/ResultsViewModel.cs index 674923228e..1496647d22 100644 --- a/Wox/ViewModel/ResultsViewModel.cs +++ b/Wox/ViewModel/ResultsViewModel.cs @@ -3,7 +3,9 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Windows; +using System.Windows.Controls; using System.Windows.Data; +using System.Windows.Documents; using Wox.Infrastructure.UserSettings; using Wox.Plugin; @@ -193,8 +195,37 @@ namespace Wox.ViewModel return results; } + #endregion + #region FormattedText Dependency Property + public static readonly DependencyProperty FormattedTextProperty = DependencyProperty.RegisterAttached( + "FormattedText", + typeof(Inline), + typeof(ResultsViewModel), + new PropertyMetadata(null, FormattedTextPropertyChanged)); + public static void SetFormattedText(DependencyObject textBlock, IList value) + { + textBlock.SetValue(FormattedTextProperty, value); + } + + public static Inline GetFormattedText(DependencyObject textBlock) + { + return (Inline)textBlock.GetValue(FormattedTextProperty); + } + + private static void FormattedTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var textBlock = d as TextBlock; + if (textBlock == null) return; + + var inline = (Inline)e.NewValue; + + textBlock.Inlines.Clear(); + if (inline == null) return; + + textBlock.Inlines.Add(inline); + } #endregion public class ResultCollection : ObservableCollection diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index ef77148291..4a4dc62bfc 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -158,6 +158,7 @@ Properties\SolutionAssemblyInfo.cs + From a004ef65aff61d0bd9088babd3a71bac7ae6e837 Mon Sep 17 00:00:00 2001 From: SysC0mp Date: Tue, 3 Dec 2019 15:10:21 +0100 Subject: [PATCH 08/17] Set title & subtitle highlight data --- Wox.Plugin/Result.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Wox.Plugin/Result.cs b/Wox.Plugin/Result.cs index 2f74591703..aff56554af 100644 --- a/Wox.Plugin/Result.cs +++ b/Wox.Plugin/Result.cs @@ -42,6 +42,16 @@ namespace Wox.Plugin public int Score { get; set; } + /// + /// A list of indexes for the characters to be highlighted in Title + /// + public IList TitleHighlightData { get; set; } + + /// + /// A list of indexes for the characters to be highlighted in SubTitle + /// + public IList SubTitleHighlightData { get; set; } + /// /// Only resulsts that originQuery match with curren query will be displayed in the panel /// @@ -69,7 +79,9 @@ namespace Wox.Plugin var equality = string.Equals(r?.Title, Title) && string.Equals(r?.SubTitle, SubTitle) && - string.Equals(r?.IcoPath, IcoPath); + string.Equals(r?.IcoPath, IcoPath) && + TitleHighlightData == r.TitleHighlightData && + SubTitleHighlightData == r.SubTitleHighlightData; return equality; } From 601d6f37af61ad14ac9493904440a3a84a99e755 Mon Sep 17 00:00:00 2001 From: SysC0mp Date: Tue, 3 Dec 2019 15:25:19 +0100 Subject: [PATCH 09/17] Highlight how results matched --- Plugins/Wox.Plugin.ControlPanel/Main.cs | 36 ++++++++------------ Plugins/Wox.Plugin.Everything/Main.cs | 2 ++ Plugins/Wox.Plugin.Folder/Main.cs | 6 ++++ Plugins/Wox.Plugin.PluginManagement/Main.cs | 5 +++ Plugins/Wox.Plugin.Program/Programs/UWP.cs | 12 +++---- Plugins/Wox.Plugin.Program/Programs/Win32.cs | 13 +++---- Plugins/Wox.Plugin.Sys/Main.cs | 15 ++++++-- 7 files changed, 52 insertions(+), 37 deletions(-) diff --git a/Plugins/Wox.Plugin.ControlPanel/Main.cs b/Plugins/Wox.Plugin.ControlPanel/Main.cs index 0e0a8898d6..77b57fe865 100644 --- a/Plugins/Wox.Plugin.ControlPanel/Main.cs +++ b/Plugins/Wox.Plugin.ControlPanel/Main.cs @@ -27,7 +27,6 @@ namespace Wox.Plugin.ControlPanel Directory.CreateDirectory(iconFolder); } - foreach (ControlPanelItem item in controlPanelItems) { if (!File.Exists(iconFolder + item.GUID + fileType) && item.Icon != null) @@ -43,7 +42,10 @@ namespace Wox.Plugin.ControlPanel foreach (var item in controlPanelItems) { - item.Score = Score(item, query.Search); + var titleMatch = StringMatcher.FuzzySearch(query.Search, item.LocalizedString); + var subTitleMatch = StringMatcher.FuzzySearch(query.Search, item.InfoTip); + + item.Score = Math.Max(titleMatch.Score, subTitleMatch.Score); if (item.Score > 0) { var result = new Result @@ -66,6 +68,16 @@ namespace Wox.Plugin.ControlPanel return true; } }; + + if (item.Score == titleMatch.Score) + { + result.TitleHighlightData = titleMatch.MatchData; + } + else + { + result.SubTitleHighlightData = subTitleMatch.MatchData; + } + results.Add(result); } } @@ -74,26 +86,6 @@ namespace Wox.Plugin.ControlPanel return panelItems; } - private int Score(ControlPanelItem item, string query) - { - var scores = new List {0}; - if (!string.IsNullOrEmpty(item.LocalizedString)) - { - var score1 = StringMatcher.FuzzySearch(query, item.LocalizedString).ScoreAfterSearchPrecisionFilter(); - var score2 = StringMatcher.ScoreForPinyin(item.LocalizedString, query); - scores.Add(score1); - scores.Add(score2); - } - if (!string.IsNullOrEmpty(item.InfoTip)) - { - var score1 = StringMatcher.FuzzySearch(query, item.InfoTip).ScoreAfterSearchPrecisionFilter(); - var score2 = StringMatcher.ScoreForPinyin(item.InfoTip, query); - scores.Add(score1); - scores.Add(score2); - } - return scores.Max(); - } - public string GetTranslatedPluginTitle() { return context.API.GetTranslation("wox_plugin_controlpanel_plugin_name"); diff --git a/Plugins/Wox.Plugin.Everything/Main.cs b/Plugins/Wox.Plugin.Everything/Main.cs index 7969a079fe..4188f89dda 100644 --- a/Plugins/Wox.Plugin.Everything/Main.cs +++ b/Plugins/Wox.Plugin.Everything/Main.cs @@ -55,6 +55,7 @@ namespace Wox.Plugin.Everything r.Title = Path.GetFileName(path); r.SubTitle = path; r.IcoPath = path; + r.TitleHighlightData = StringMatcher.FuzzySearch(keyword, Path.GetFileName(path)).MatchData; r.Action = c => { bool hide; @@ -78,6 +79,7 @@ namespace Wox.Plugin.Everything return hide; }; r.ContextData = s; + r.SubTitleHighlightData = StringMatcher.FuzzySearch(keyword, path).MatchData; results.Add(r); } } diff --git a/Plugins/Wox.Plugin.Folder/Main.cs b/Plugins/Wox.Plugin.Folder/Main.cs index e8f33a951b..f3aef7d1d5 100644 --- a/Plugins/Wox.Plugin.Folder/Main.cs +++ b/Plugins/Wox.Plugin.Folder/Main.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Windows; using System.Windows.Controls; +using Wox.Infrastructure; using Wox.Infrastructure.Storage; namespace Wox.Plugin.Folder @@ -53,6 +54,7 @@ namespace Wox.Plugin.Folder Title = item.Nickname, IcoPath = item.Path, SubTitle = "Ctrl + Enter to open the directory", + TitleHighlightData = StringMatcher.FuzzySearch(item.Nickname, search).MatchData, Action = c => { if (c.SpecialKeyState.CtrlPressed) @@ -148,6 +150,8 @@ namespace Wox.Plugin.Folder } }); + string searchNickname = new FolderLink { Path = query.Search }.Nickname; + //Add children directories DirectoryInfo[] dirs = new DirectoryInfo(search).GetDirectories(); foreach (DirectoryInfo dir in dirs) @@ -162,6 +166,7 @@ namespace Wox.Plugin.Folder Title = dir.Name, IcoPath = dir.FullName, SubTitle = "Ctrl + Enter to open the directory", + TitleHighlightData = StringMatcher.FuzzySearch(dir.Name, searchNickname).MatchData, Action = c => { if (c.SpecialKeyState.CtrlPressed) @@ -197,6 +202,7 @@ namespace Wox.Plugin.Folder { Title = Path.GetFileName(filePath), IcoPath = filePath, + TitleHighlightData = StringMatcher.FuzzySearch(file.Name, searchNickname).MatchData, Action = c => { try diff --git a/Plugins/Wox.Plugin.PluginManagement/Main.cs b/Plugins/Wox.Plugin.PluginManagement/Main.cs index 785ca3b1f3..1ee0fd7ae8 100644 --- a/Plugins/Wox.Plugin.PluginManagement/Main.cs +++ b/Plugins/Wox.Plugin.PluginManagement/Main.cs @@ -8,6 +8,7 @@ using System.Threading; using System.Threading.Tasks; using System.Windows; using Newtonsoft.Json; +using Wox.Infrastructure; using Wox.Infrastructure.Http; using Wox.Infrastructure.Logger; @@ -142,6 +143,8 @@ namespace Wox.Plugin.PluginManagement Title = r.name, SubTitle = r.description, IcoPath = "Images\\plugin.png", + TitleHighlightData = StringMatcher.FuzzySearch(query.SecondSearch, r.name).MatchData, + SubTitleHighlightData = StringMatcher.FuzzySearch(query.SecondSearch, r.description).MatchData, Action = c => { MessageBoxResult result = MessageBox.Show("Are you sure you wish to install the \'" + r.name + "\' plugin", @@ -191,6 +194,8 @@ namespace Wox.Plugin.PluginManagement Title = plugin.Name, SubTitle = plugin.Description, IcoPath = plugin.IcoPath, + TitleHighlightData = StringMatcher.FuzzySearch(query.SecondSearch, plugin.Name).MatchData, + SubTitleHighlightData = StringMatcher.FuzzySearch(query.SecondSearch, plugin.Description).MatchData, Action = e => { UnInstallPlugin(plugin); diff --git a/Plugins/Wox.Plugin.Program/Programs/UWP.cs b/Plugins/Wox.Plugin.Program/Programs/UWP.cs index 77d33e2e2f..3cd75fbae2 100644 --- a/Plugins/Wox.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Wox.Plugin.Program/Programs/UWP.cs @@ -35,7 +35,6 @@ namespace Wox.Plugin.Program.Programs public UWP(Package package) { - Location = package.InstalledLocation.Path; Name = package.Id.Name; FullName = package.Id.FullName; @@ -266,11 +265,9 @@ namespace Wox.Plugin.Program.Programs private int Score(string query) { - var score1 = StringMatcher.FuzzySearch(query, DisplayName).ScoreAfterSearchPrecisionFilter(); - var score2 = StringMatcher.ScoreForPinyin(DisplayName, query); - var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter(); - var score4 = StringMatcher.ScoreForPinyin(Description, query); - var score = new[] { score1, score2, score3, score4 }.Max(); + var displayNameMatch = StringMatcher.FuzzySearch(query, DisplayName); + var descriptionMatch = StringMatcher.FuzzySearch(query, Description); + var score = new[] { displayNameMatch.Score, descriptionMatch.Score }.Max(); return score; } @@ -293,14 +290,17 @@ namespace Wox.Plugin.Program.Programs Description.Substring(0, DisplayName.Length) == DisplayName) { result.Title = Description; + result.TitleHighlightData = StringMatcher.FuzzySearch(query, Description).MatchData; } else if (!string.IsNullOrEmpty(Description)) { result.Title = $"{DisplayName}: {Description}"; + result.TitleHighlightData = StringMatcher.FuzzySearch(query, DisplayName).MatchData; } else { result.Title = DisplayName; + result.TitleHighlightData = StringMatcher.FuzzySearch(query, DisplayName).MatchData; } return result; } diff --git a/Plugins/Wox.Plugin.Program/Programs/Win32.cs b/Plugins/Wox.Plugin.Program/Programs/Win32.cs index dc11a56654..b6a5cf01c9 100644 --- a/Plugins/Wox.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Wox.Plugin.Program/Programs/Win32.cs @@ -33,12 +33,10 @@ namespace Wox.Plugin.Program.Programs private int Score(string query) { - var score1 = StringMatcher.FuzzySearch(query, Name).ScoreAfterSearchPrecisionFilter(); - var score2 = StringMatcher.ScoreForPinyin(Name, query); - var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter(); - var score4 = StringMatcher.ScoreForPinyin(Description, query); - var score5 = StringMatcher.FuzzySearch(query, ExecutableName).ScoreAfterSearchPrecisionFilter(); - var score = new[] { score1, score2, score3, score4, score5 }.Max(); + var nameMatch = StringMatcher.FuzzySearch(query, Name); + var descriptionMatch = StringMatcher.FuzzySearch(query, Description); + var executableNameMatch = StringMatcher.FuzzySearch(query, ExecutableName); + var score = new[] { nameMatch.Score, descriptionMatch.Score, executableNameMatch.Score }.Max(); return score; } @@ -67,14 +65,17 @@ namespace Wox.Plugin.Program.Programs Description.Substring(0, Name.Length) == Name) { result.Title = Description; + result.TitleHighlightData = StringMatcher.FuzzySearch(query, Description).MatchData; } else if (!string.IsNullOrEmpty(Description)) { result.Title = $"{Name}: {Description}"; + result.TitleHighlightData = StringMatcher.FuzzySearch(query, Description).MatchData; } else { result.Title = Name; + result.TitleHighlightData = StringMatcher.FuzzySearch(query, Name).MatchData; } return result; diff --git a/Plugins/Wox.Plugin.Sys/Main.cs b/Plugins/Wox.Plugin.Sys/Main.cs index 32e888514d..e888dbb378 100644 --- a/Plugins/Wox.Plugin.Sys/Main.cs +++ b/Plugins/Wox.Plugin.Sys/Main.cs @@ -56,12 +56,21 @@ namespace Wox.Plugin.Sys var results = new List(); foreach (var c in commands) { - var titleScore = StringMatcher.FuzzySearch(query.Search, c.Title).ScoreAfterSearchPrecisionFilter(); - var subTitleScore = StringMatcher.FuzzySearch(query.Search, c.SubTitle).ScoreAfterSearchPrecisionFilter(); - var score = Math.Max(titleScore, subTitleScore); + var titleMatch = StringMatcher.FuzzySearch(query.Search, c.Title); + var subTitleMatch = StringMatcher.FuzzySearch(query.Search, c.SubTitle); + + var score = Math.Max(titleMatch.Score, subTitleMatch.Score); if (score > 0) { c.Score = score; + if (score == titleMatch.Score) + { + c.TitleHighlightData = titleMatch.MatchData; + } + else + { + c.SubTitleHighlightData = subTitleMatch.MatchData; + } results.Add(c); } } From f4a2f67db389260f7744f1ed992638ba412063f8 Mon Sep 17 00:00:00 2001 From: SysC0mp Date: Tue, 3 Dec 2019 19:22:03 +0100 Subject: [PATCH 10/17] Fix wrong comparison parameter Wrong string was used for FuzzySearch comparison which resulted wrong highlighted letters in the results. --- Plugins/Wox.Plugin.Program/Programs/Win32.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Wox.Plugin.Program/Programs/Win32.cs b/Plugins/Wox.Plugin.Program/Programs/Win32.cs index b6a5cf01c9..b9a6e401c3 100644 --- a/Plugins/Wox.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Wox.Plugin.Program/Programs/Win32.cs @@ -69,8 +69,9 @@ namespace Wox.Plugin.Program.Programs } else if (!string.IsNullOrEmpty(Description)) { - result.Title = $"{Name}: {Description}"; - result.TitleHighlightData = StringMatcher.FuzzySearch(query, Description).MatchData; + var title = $"{Name}: {Description}"; + result.Title = title; + result.TitleHighlightData = StringMatcher.FuzzySearch(query, title).MatchData; } else { From 78f243651e82155b5cb80b70e5aaa1dfc3899b8f Mon Sep 17 00:00:00 2001 From: SysC0mp Date: Mon, 9 Dec 2019 20:47:24 +0100 Subject: [PATCH 11/17] Pass Settings instance to Alphabet again --- Wox.Infrastructure/Alphabet.cs | 21 +++++++++------------ Wox/App.xaml.cs | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Wox.Infrastructure/Alphabet.cs b/Wox.Infrastructure/Alphabet.cs index a2f64241a4..ee6b84b418 100644 --- a/Wox.Infrastructure/Alphabet.cs +++ b/Wox.Infrastructure/Alphabet.cs @@ -15,15 +15,12 @@ namespace Wox.Infrastructure private static readonly HanyuPinyinOutputFormat Format = new HanyuPinyinOutputFormat(); private static ConcurrentDictionary PinyinCache; private static BinaryStorage> _pinyinStorage; - private static bool _shouldUsePinyin = true; + private static Settings _settings; - public static void Initialize(bool shouldUsePinyin = true) + public static void Initialize(Settings settings) { - _shouldUsePinyin = shouldUsePinyin; - if (_shouldUsePinyin) - { - InitializePinyinHelpers(); - } + _settings = settings; + InitializePinyinHelpers(); } private static void InitializePinyinHelpers() @@ -43,7 +40,7 @@ namespace Wox.Infrastructure public static void Save() { - if (!_shouldUsePinyin) + if (!_settings.ShouldUsePinyin) { return; } @@ -59,7 +56,7 @@ namespace Wox.Infrastructure /// public static string[] Pinyin(string word) { - if (!_shouldUsePinyin) + if (!_settings.ShouldUsePinyin) { return EmptyStringArray; } @@ -81,7 +78,7 @@ namespace Wox.Infrastructure /// public static string[][] PinyinComination(string characters) { - if (!_shouldUsePinyin || string.IsNullOrEmpty(characters)) + if (!_settings.ShouldUsePinyin || string.IsNullOrEmpty(characters)) { return Empty2DStringArray; } @@ -122,7 +119,7 @@ namespace Wox.Infrastructure public static bool ContainsChinese(string word) { - if (!_shouldUsePinyin) + if (!_settings.ShouldUsePinyin) { return false; } @@ -140,7 +137,7 @@ namespace Wox.Infrastructure private static string[] Combination(string[] array1, string[] array2) { - if (!_shouldUsePinyin) + if (!_settings.ShouldUsePinyin) { return EmptyStringArray; } diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index acfb88d266..8cdc4a8b85 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -53,7 +53,7 @@ namespace Wox _settingsVM = new SettingWindowViewModel(); _settings = _settingsVM.Settings; - Alphabet.Initialize(_settings.ShouldUsePinyin); + Alphabet.Initialize(_settings); StringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision; From 49c5c5bbdeb355541c587f9f60f5f432a491bc1d Mon Sep 17 00:00:00 2001 From: SysC0mp Date: Mon, 9 Dec 2019 20:57:59 +0100 Subject: [PATCH 12/17] 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. --- Wox.Infrastructure/StringMatcher.cs | 8 +++++++- Wox.Infrastructure/UserSettings/Settings.cs | 12 +++++++++++- Wox/App.xaml.cs | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Wox.Infrastructure/StringMatcher.cs b/Wox.Infrastructure/StringMatcher.cs index dd5a118fb4..baca1020f2 100644 --- a/Wox.Infrastructure/StringMatcher.cs +++ b/Wox.Infrastructure/StringMatcher.cs @@ -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)) diff --git a/Wox.Infrastructure/UserSettings/Settings.cs b/Wox.Infrastructure/UserSettings/Settings.cs index 7371ea5d05..de5a2e6624 100644 --- a/Wox.Infrastructure/UserSettings/Settings.cs +++ b/Wox.Infrastructure/UserSettings/Settings.cs @@ -24,7 +24,17 @@ namespace Wox.Infrastructure.UserSettings /// /// when false Alphabet static service will always return empty results /// - 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 diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index 8cdc4a8b85..9436df4758 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -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); From e60797cd0f55d5566c54bb755dd3c998633f7b33 Mon Sep 17 00:00:00 2001 From: SysC0mp Date: Mon, 9 Dec 2019 21:06:31 +0100 Subject: [PATCH 13/17] Introduce RawScore property New property RawScore is used to save the calculated score without any search precision filtering added. --- Wox.Infrastructure/StringMatcher.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Wox.Infrastructure/StringMatcher.cs b/Wox.Infrastructure/StringMatcher.cs index baca1020f2..f350e0e404 100644 --- a/Wox.Infrastructure/StringMatcher.cs +++ b/Wox.Infrastructure/StringMatcher.cs @@ -96,7 +96,7 @@ namespace Wox.Infrastructure { Success = true, MatchData = indexList, - Score = Math.Max(score, pinyinScore) + RawScore = Math.Max(score, pinyinScore) }; return result.Score > 0 ? @@ -171,16 +171,22 @@ namespace Wox.Infrastructure { public bool Success { get; set; } - private int _score; - public int Score + /// + /// The final score of the match result with all search precision filters applied. + /// + public int Score { get; private set; } + + /// + /// The raw calculated search score without any search precision filtering applied. + /// + private int _rawScore; + public int RawScore { - get - { - return _score; - } + get { return _rawScore; } set { - _score = ApplySearchPrecisionFilter(value); + _rawScore = value; + Score = ApplySearchPrecisionFilter(_rawScore); } } From ce89ff3c85bbe3f0bc05650fb392ee48cc7c1222 Mon Sep 17 00:00:00 2001 From: SysC0mp Date: Mon, 9 Dec 2019 21:08:17 +0100 Subject: [PATCH 14/17] FIx test methods Use RawScore or Score depending on the test case. Also removed unnecessary test settings introduced earlier. --- Wox.Test/FuzzyMatcherTest.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Wox.Test/FuzzyMatcherTest.cs b/Wox.Test/FuzzyMatcherTest.cs index aa8778a54c..21563f91f9 100644 --- a/Wox.Test/FuzzyMatcherTest.cs +++ b/Wox.Test/FuzzyMatcherTest.cs @@ -12,7 +12,7 @@ namespace Wox.Test [TestFixture] public class FuzzyMatcherTest { - public List GetSearchStrings() + public List GetSearchStrings() => new List { "Chrome", @@ -49,16 +49,13 @@ namespace Wox.Test "aac" }; - Alphabet.Initialize(false); - StringMatcher.UserSettingSearchPrecision = StringMatcher.SearchPrecisionScore.Low.ToString(); - var results = new List(); foreach (var str in sources) { results.Add(new Result { Title = str, - Score = StringMatcher.FuzzySearch("inst", str).Score + Score = StringMatcher.FuzzySearch("inst", str).RawScore }); } @@ -75,7 +72,7 @@ namespace Wox.Test { var compareString = "Can have rum only in my glass"; - var scoreResult = StringMatcher.FuzzySearch(searchString, compareString).Score; + var scoreResult = StringMatcher.FuzzySearch(searchString, compareString).RawScore; Assert.True(scoreResult == 0); } @@ -132,16 +129,12 @@ namespace Wox.Test .ToList(); var results = new List(); - - Alphabet.Initialize(false); - StringMatcher.UserSettingSearchPrecision = StringMatcher.SearchPrecisionScore.None.ToString(); - foreach (var str in searchStrings) { results.Add(new Result { Title = str, - Score = StringMatcher.FuzzySearch(searchTerm, str).Score + Score = StringMatcher.FuzzySearch(searchTerm, str).RawScore }); } From 7d5c827dec085d29e4631b4a8be96c363d60e4cf Mon Sep 17 00:00:00 2001 From: SysC0mp Date: Mon, 9 Dec 2019 21:08:38 +0100 Subject: [PATCH 15/17] Remove whitespace --- Wox.Infrastructure/Alphabet.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Wox.Infrastructure/Alphabet.cs b/Wox.Infrastructure/Alphabet.cs index ee6b84b418..63e178ba1e 100644 --- a/Wox.Infrastructure/Alphabet.cs +++ b/Wox.Infrastructure/Alphabet.cs @@ -149,7 +149,5 @@ namespace Wox.Infrastructure ).ToArray(); return combination; } - - } } From 971e1cdbecb8278604c131eabaa4c704f08d17d5 Mon Sep 17 00:00:00 2001 From: SysC0mp Date: Wed, 11 Dec 2019 19:08:52 +0100 Subject: [PATCH 16/17] Fix highlighting for UWP results --- Plugins/Wox.Plugin.Program/Programs/UWP.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Wox.Plugin.Program/Programs/UWP.cs b/Plugins/Wox.Plugin.Program/Programs/UWP.cs index b86cad51cf..9d893e7659 100644 --- a/Plugins/Wox.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Wox.Plugin.Program/Programs/UWP.cs @@ -300,8 +300,9 @@ namespace Wox.Plugin.Program.Programs } else if (!string.IsNullOrEmpty(Description)) { - result.Title = $"{DisplayName}: {Description}"; - result.TitleHighlightData = StringMatcher.FuzzySearch(query, DisplayName).MatchData; + var title = $"{DisplayName}: {Description}"; + result.Title = title; + result.TitleHighlightData = StringMatcher.FuzzySearch(query, title).MatchData; } else { From 0f9da7f5194486f1eb84562a13df804dfff3c1fa Mon Sep 17 00:00:00 2001 From: SysC0mp Date: Wed, 11 Dec 2019 19:10:11 +0100 Subject: [PATCH 17/17] Always return filled result again --- Plugins/Wox.Plugin.Program/Main.cs | 4 ++-- Wox.Infrastructure/StringMatcher.cs | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Plugins/Wox.Plugin.Program/Main.cs b/Plugins/Wox.Plugin.Program/Main.cs index a37e9f2028..106ac9cfa7 100644 --- a/Plugins/Wox.Plugin.Program/Main.cs +++ b/Plugins/Wox.Plugin.Program/Main.cs @@ -78,8 +78,8 @@ namespace Wox.Plugin.Program } var results1 = win32.AsParallel() - .Where(p => p.Enabled) - .Select(p => p.Result(query.Search, _context.API)); + .Where(p => p.Enabled) + .Select(p => p.Result(query.Search, _context.API)); var results2 = uwps.AsParallel() .Where(p => p.Enabled) diff --git a/Wox.Infrastructure/StringMatcher.cs b/Wox.Infrastructure/StringMatcher.cs index f350e0e404..58ffa336fc 100644 --- a/Wox.Infrastructure/StringMatcher.cs +++ b/Wox.Infrastructure/StringMatcher.cs @@ -99,9 +99,7 @@ namespace Wox.Infrastructure RawScore = Math.Max(score, pinyinScore) }; - return result.Score > 0 ? - result : - new MatchResult { Success = false }; + return result; } return new MatchResult { Success = false };