From bb6a91124a8901e0d431a68d7a4d0681bbf01580 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 1 Feb 2021 06:50:53 +1100 Subject: [PATCH] add loop to check remaining acronyms if previous matched --- Flow.Launcher.Infrastructure/StringMatcher.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Flow.Launcher.Infrastructure/StringMatcher.cs b/Flow.Launcher.Infrastructure/StringMatcher.cs index c8f22cf7c..2042b73f7 100644 --- a/Flow.Launcher.Infrastructure/StringMatcher.cs +++ b/Flow.Launcher.Infrastructure/StringMatcher.cs @@ -68,6 +68,8 @@ namespace Flow.Launcher.Infrastructure // preset acronymScore int acronymScore = 100; + int acronymsRemainingNotMatched = 0; + int acronymsMatched = 0; var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToLower() : stringToCompare; var queryWithoutCase = opt.IgnoreCase ? query.ToLower() : query; @@ -91,6 +93,15 @@ namespace Flow.Launcher.Infrastructure 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 || allQuerySubstringsMatched && acronymScore < (int) UserSettingSearchPrecision) break; @@ -118,11 +129,13 @@ namespace Flow.Launcher.Infrastructure char.IsDigit(currentCompareChar)) { acronymMatchData.Add(compareStringIndex); + acronymsMatched++; } } else if (!(spaceMet = char.IsWhiteSpace(stringToCompare[compareStringIndex]))) { acronymMatchData.Add(compareStringIndex); + acronymsMatched++; } currentAcronymQueryIndex++;