add loop to check remaining acronyms if previous matched

This commit is contained in:
Jeremy Wu 2021-02-01 06:50:53 +11:00
parent c395cc74b5
commit bb6a91124a

View file

@ -68,6 +68,8 @@ namespace Flow.Launcher.Infrastructure
// preset acronymScore // preset acronymScore
int acronymScore = 100; int acronymScore = 100;
int acronymsRemainingNotMatched = 0;
int acronymsMatched = 0;
var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToLower() : stringToCompare; var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToLower() : stringToCompare;
var queryWithoutCase = opt.IgnoreCase ? query.ToLower() : query; var queryWithoutCase = opt.IgnoreCase ? query.ToLower() : query;
@ -91,6 +93,15 @@ namespace Flow.Launcher.Infrastructure
for (var compareStringIndex = 0; compareStringIndex < fullStringToCompareWithoutCase.Length; compareStringIndex++) for (var compareStringIndex = 0; compareStringIndex < fullStringToCompareWithoutCase.Length; compareStringIndex++)
{ {
if (currentAcronymQueryIndex >= queryWithoutCase.Length && acronymsMatched > 0)
{
if (char.IsUpper(stringToCompare[compareStringIndex]) ||
char.IsNumber(stringToCompare[compareStringIndex]) ||
char.IsWhiteSpace(stringToCompare[compareStringIndex]))
acronymsRemainingNotMatched++;
continue;
}
if (currentAcronymQueryIndex >= queryWithoutCase.Length if (currentAcronymQueryIndex >= queryWithoutCase.Length
|| allQuerySubstringsMatched && acronymScore < (int) UserSettingSearchPrecision) || allQuerySubstringsMatched && acronymScore < (int) UserSettingSearchPrecision)
break; break;
@ -118,11 +129,13 @@ namespace Flow.Launcher.Infrastructure
char.IsDigit(currentCompareChar)) char.IsDigit(currentCompareChar))
{ {
acronymMatchData.Add(compareStringIndex); acronymMatchData.Add(compareStringIndex);
acronymsMatched++;
} }
} }
else if (!(spaceMet = char.IsWhiteSpace(stringToCompare[compareStringIndex]))) else if (!(spaceMet = char.IsWhiteSpace(stringToCompare[compareStringIndex])))
{ {
acronymMatchData.Add(compareStringIndex); acronymMatchData.Add(compareStringIndex);
acronymsMatched++;
} }
currentAcronymQueryIndex++; currentAcronymQueryIndex++;