From b54241a5b27d4802e976f2f1b9571a4c4d6f2d36 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 7 Jan 2020 08:28:27 +1100 Subject: [PATCH] Update scoring for all substrings contained in compare string --- Wox.Infrastructure/StringMatcher.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Wox.Infrastructure/StringMatcher.cs b/Wox.Infrastructure/StringMatcher.cs index 27f99b2a6..45d65549a 100644 --- a/Wox.Infrastructure/StringMatcher.cs +++ b/Wox.Infrastructure/StringMatcher.cs @@ -192,7 +192,7 @@ namespace Wox.Infrastructure return currentQuerySubstringIndex >= querySubstringsLength; } - private static int CalculateSearchScore(string query, string stringToCompare, int firstIndex, int matchLen, bool allWordsFullyMatched) + private static int CalculateSearchScore(string query, string stringToCompare, int firstIndex, int matchLen, bool allSubstringsContainedInCompareString) { // 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, @@ -209,10 +209,8 @@ namespace Wox.Infrastructure score += 10; } - if (allWordsFullyMatched) - { - score += 20; - } + if (allSubstringsContainedInCompareString) + score += 10 * string.Concat(query.Where(c => !char.IsWhiteSpace(c))).Count(); return score; }