Skip to content

Commit 592f1ca

Browse files
committed
update allSubstringsContainedInCompareString calculation as per comment
1 parent 71d8c20 commit 592f1ca

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Wox.Infrastructure/StringMatcher.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,11 @@ private static int CalculateSearchScore(string query, string stringToCompare, in
210210
}
211211

212212
if (allSubstringsContainedInCompareString)
213-
score += 10 * string.Concat(query.Where(c => !char.IsWhiteSpace(c))).Count();
213+
{
214+
int count = query.Count(c => !char.IsWhiteSpace(c));
215+
int factor = count < 4 ? 10 : 5;
216+
score += factor * count;
217+
}
214218

215219
return score;
216220
}

Wox.Test/FuzzyMatcherTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ public void WhenGivenStringsAndAppliedPrecisionFilteringThenShouldReturnGreaterT
121121
}
122122
}
123123

124-
[TestCase(Chrome, Chrome, 167)]
125-
[TestCase(Chrome, LastIsChrome, 113)]
124+
[TestCase(Chrome, Chrome, 137)]
125+
[TestCase(Chrome, LastIsChrome, 83)]
126126
[TestCase(Chrome, HelpCureHopeRaiseOnMindEntityChrome, 21)]
127127
[TestCase(Chrome, UninstallOrChangeProgramsOnYourComputer, 15)]
128128
[TestCase(Chrome, CandyCrushSagaFromKing, 0)]
129129
[TestCase("sql", MicrosoftSqlServerManagementStudio, 56)]
130-
[TestCase("sql manag", MicrosoftSqlServerManagementStudio, 119)]//double spacing intended
130+
[TestCase("sql manag", MicrosoftSqlServerManagementStudio, 79)]//double spacing intended
131131
public void WhenGivenQueryStringThenShouldReturnCurrentScoring(string queryString, string compareString, int expectedScore)
132132
{
133133
// When, Given

0 commit comments

Comments
 (0)