11using System ;
22using System . Buffers ;
33using System . Collections . Generic ;
4- using System . Globalization ;
54using System . Linq ;
6- using System . Text ;
75using CommunityToolkit . Mvvm . DependencyInjection ;
86using Flow . Launcher . Infrastructure . UserSettings ;
97using Flow . Launcher . Plugin . SharedModels ;
@@ -21,16 +19,13 @@ public class StringMatcher
2119 public StringMatcher ( IAlphabet alphabet , Settings settings )
2220 {
2321 _alphabet = alphabet ;
24- UserSettingSearchPrecision = settings . QuerySearchPrecision ;
2522 _settings = settings ;
23+ UserSettingSearchPrecision = _settings . QuerySearchPrecision ;
2624 }
2725
2826 // This is a workaround to allow unit tests to set the instance
29- public StringMatcher ( IAlphabet alphabet )
27+ public StringMatcher ( IAlphabet alphabet ) : this ( alphabet , new Settings ( ) )
3028 {
31- _alphabet = alphabet ;
32- _settings = new Settings ( ) ;
33- UserSettingSearchPrecision = _settings . QuerySearchPrecision ;
3429 }
3530
3631 public static MatchResult FuzzySearch ( string query , string stringToCompare )
@@ -101,8 +96,7 @@ public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption
10196 queryToCompare = queryToCompare . ToLower ( ) ;
10297 }
10398
104-
105- var querySubstrings = queryToCompare . Split ( new [ ] { ' ' } , StringSplitOptions . RemoveEmptyEntries ) ;
99+ var querySubstrings = queryToCompare . Split ( [ ' ' ] , StringSplitOptions . RemoveEmptyEntries ) ;
106100 int currentQuerySubstringIndex = 0 ;
107101 var currentQuerySubstring = querySubstrings [ currentQuerySubstringIndex ] ;
108102 var currentQuerySubstringCharacterIndex = 0 ;
@@ -180,8 +174,8 @@ public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption
180174 // in order to do so we need to verify all previous chars are part of the pattern
181175 var startIndexToVerify = compareStringIndex - currentQuerySubstringCharacterIndex ;
182176
183- if ( AllPreviousCharsMatched ( startIndexToVerify , currentQuerySubstringCharacterIndex ,
184- fullStringToCompare , currentQuerySubstring ) )
177+ if ( AllPreviousCharsMatched ( startIndexToVerify , currentQuerySubstringCharacterIndex ,
178+ fullStringToCompare , currentQuerySubstring ) )
185179 {
186180 matchFoundInPreviousLoop = true ;
187181
0 commit comments