File tree Expand file tree Collapse file tree 3 files changed +15
-12
lines changed
Flow.Launcher.Infrastructure Expand file tree Collapse file tree 3 files changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -25,11 +25,9 @@ public StringMatcher(IAlphabet alphabet)
2525 _alphabet = alphabet ;
2626 }
2727
28- public static StringMatcher Instance { get ; internal set ; }
29-
3028 public static MatchResult FuzzySearch ( string query , string stringToCompare )
3129 {
32- return Instance . FuzzyMatch ( query , stringToCompare ) ;
30+ return Ioc . Default . GetRequiredService < StringMatcher > ( ) . FuzzyMatch ( query , stringToCompare ) ;
3331 }
3432
3533 public MatchResult FuzzyMatch ( string query , string stringToCompare )
Original file line number Diff line number Diff line change 33using System . Drawing ;
44using System . Text . Json . Serialization ;
55using System . Windows ;
6+ using CommunityToolkit . Mvvm . DependencyInjection ;
67using Flow . Launcher . Infrastructure . Hotkey ;
78using Flow . Launcher . Infrastructure . Storage ;
89using Flow . Launcher . Plugin ;
@@ -14,12 +15,18 @@ namespace Flow.Launcher.Infrastructure.UserSettings
1415 public class Settings : BaseModel , IHotkeySettings
1516 {
1617 private FlowLauncherJsonStorage < Settings > _storage ;
18+ private StringMatcher _stringMatcher = null ;
1719
18- public void Initialize ( FlowLauncherJsonStorage < Settings > storage )
20+ public void SetStorage ( FlowLauncherJsonStorage < Settings > storage )
1921 {
2022 _storage = storage ;
2123 }
2224
25+ public void Initialize ( )
26+ {
27+ _stringMatcher = Ioc . Default . GetRequiredService < StringMatcher > ( ) ;
28+ }
29+
2330 public void Save ( )
2431 {
2532 _storage . Save ( ) ;
@@ -192,7 +199,6 @@ public CustomBrowserViewModel CustomBrowser
192199 }
193200 } ;
194201
195-
196202 /// <summary>
197203 /// when false Alphabet static service will always return empty results
198204 /// </summary>
@@ -210,8 +216,8 @@ public SearchPrecisionScore QuerySearchPrecision
210216 set
211217 {
212218 _querySearchPrecision = value ;
213- if ( StringMatcher . Instance != null )
214- StringMatcher . Instance . UserSettingSearchPrecision = value ;
219+ if ( _stringMatcher != null )
220+ _stringMatcher . UserSettingSearchPrecision = value ;
215221 }
216222 }
217223
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ public App()
3737 // Initialize settings
3838 var storage = new FlowLauncherJsonStorage < Settings > ( ) ;
3939 _settings = storage . Load ( ) ;
40- _settings . Initialize ( storage ) ;
40+ _settings . SetStorage ( storage ) ;
4141 _settings . WMPInstalled = WindowsMediaPlayerHelper . IsWindowsMediaPlayerInstalled ( ) ;
4242
4343 // Configure the dependency injection container
@@ -55,8 +55,9 @@ public App()
5555 ) . Build ( ) ;
5656 Ioc . Default . ConfigureServices ( host . Services ) ;
5757
58- // Initialize the public API first
58+ // Initialize the public API and Settings first
5959 API = Ioc . Default . GetRequiredService < IPublicAPI > ( ) ;
60+ _settings . Initialize ( ) ;
6061 }
6162
6263 [ STAThread ]
@@ -90,9 +91,7 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
9091
9192 AbstractPluginEnvironment . PreStartPluginExecutablePathUpdate ( _settings ) ;
9293
93- var stringMatcher = Ioc . Default . GetRequiredService < StringMatcher > ( ) ;
94- StringMatcher . Instance = stringMatcher ;
95- stringMatcher . UserSettingSearchPrecision = _settings . QuerySearchPrecision ;
94+ Ioc . Default . GetRequiredService < StringMatcher > ( ) . UserSettingSearchPrecision = _settings . QuerySearchPrecision ;
9695
9796 InternationalizationManager . Instance . Settings = _settings ;
9897 InternationalizationManager . Instance . ChangeLanguage ( _settings . Language ) ;
You can’t perform that action at this time.
0 commit comments