Skip to content

Commit bb6a911

Browse files
committed
add loop to check remaining acronyms if previous matched
1 parent c395cc7 commit bb6a911

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Flow.Launcher.Infrastructure/StringMatcher.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption
6868

6969
// preset acronymScore
7070
int acronymScore = 100;
71+
int acronymsRemainingNotMatched = 0;
72+
int acronymsMatched = 0;
7173

7274
var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToLower() : stringToCompare;
7375
var queryWithoutCase = opt.IgnoreCase ? query.ToLower() : query;
@@ -91,6 +93,15 @@ public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption
9193

9294
for (var compareStringIndex = 0; compareStringIndex < fullStringToCompareWithoutCase.Length; compareStringIndex++)
9395
{
96+
if (currentAcronymQueryIndex >= queryWithoutCase.Length && acronymsMatched > 0)
97+
{
98+
if (char.IsUpper(stringToCompare[compareStringIndex]) ||
99+
char.IsNumber(stringToCompare[compareStringIndex]) ||
100+
char.IsWhiteSpace(stringToCompare[compareStringIndex]))
101+
acronymsRemainingNotMatched++;
102+
continue;
103+
}
104+
94105
if (currentAcronymQueryIndex >= queryWithoutCase.Length
95106
|| allQuerySubstringsMatched && acronymScore < (int) UserSettingSearchPrecision)
96107
break;
@@ -118,11 +129,13 @@ public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption
118129
char.IsDigit(currentCompareChar))
119130
{
120131
acronymMatchData.Add(compareStringIndex);
132+
acronymsMatched++;
121133
}
122134
}
123135
else if (!(spaceMet = char.IsWhiteSpace(stringToCompare[compareStringIndex])))
124136
{
125137
acronymMatchData.Add(compareStringIndex);
138+
acronymsMatched++;
126139
}
127140

128141
currentAcronymQueryIndex++;

0 commit comments

Comments
 (0)