diff --git a/Flow.Launcher.Infrastructure/PinyinAlphabet.cs b/Flow.Launcher.Infrastructure/PinyinAlphabet.cs index f1557c45a..6c2a94e82 100644 --- a/Flow.Launcher.Infrastructure/PinyinAlphabet.cs +++ b/Flow.Launcher.Infrastructure/PinyinAlphabet.cs @@ -45,7 +45,6 @@ namespace Flow.Launcher.Infrastructure int count = 0; - // Corner case handle if (translatedIndex < translatedIndexs[0]) return translatedIndex; @@ -113,7 +112,6 @@ namespace Flow.Launcher.Infrastructure private ConcurrentDictionary _pinyinCache = new ConcurrentDictionary(); - private Settings _settings; public void Initialize([NotNull] Settings settings) diff --git a/Flow.Launcher.Infrastructure/StringMatcher.cs b/Flow.Launcher.Infrastructure/StringMatcher.cs index 63722bd54..916168dfe 100644 --- a/Flow.Launcher.Infrastructure/StringMatcher.cs +++ b/Flow.Launcher.Infrastructure/StringMatcher.cs @@ -47,17 +47,17 @@ namespace Flow.Launcher.Infrastructure return new MatchResult(false, UserSettingSearchPrecision); query = query.Trim(); - TranslationMapping map; - (stringToCompare, map) = _alphabet?.Translate(stringToCompare) ?? (stringToCompare, null); + TranslationMapping translationMapping; + (stringToCompare, translationMapping) = _alphabet?.Translate(stringToCompare) ?? (stringToCompare, null); var currentAcronymQueryIndex = 0; var acronymMatchData = new List(); - var queryWithoutCase = opt.IgnoreCase ? query.ToLower() : query; // preset acronymScore int acronymScore = 100; var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToLower() : stringToCompare; + var queryWithoutCase = opt.IgnoreCase ? query.ToLower() : query; var querySubstrings = queryWithoutCase.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); int currentQuerySubstringIndex = 0; @@ -136,7 +136,6 @@ namespace Flow.Launcher.Infrastructure continue; } - if (firstMatchIndex < 0) { // first matched char will become the start of the compared string @@ -197,7 +196,7 @@ namespace Flow.Launcher.Infrastructure // return acronym Match if possible if (acronymMatchData.Count == query.Length && acronymScore >= (int) UserSettingSearchPrecision) { - acronymMatchData = acronymMatchData.Select(x => map?.MapToOriginalIndex(x) ?? x).Distinct().ToList(); + acronymMatchData = acronymMatchData.Select(x => translationMapping?.MapToOriginalIndex(x) ?? x).Distinct().ToList(); return new MatchResult(true, UserSettingSearchPrecision, acronymMatchData, acronymScore); } @@ -208,7 +207,7 @@ namespace Flow.Launcher.Infrastructure var score = CalculateSearchScore(query, stringToCompare, firstMatchIndex - nearestSpaceIndex - 1, lastMatchIndex - firstMatchIndex, allSubstringsContainedInCompareString); - var resultList = indexList.Select(x => map?.MapToOriginalIndex(x) ?? x).Distinct().ToList(); + var resultList = indexList.Select(x => translationMapping?.MapToOriginalIndex(x) ?? x).Distinct().ToList(); return new MatchResult(true, UserSettingSearchPrecision, resultList, score); }