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)
25
25
_alphabet = alphabet ;
26
26
}
27
27
28
- public static StringMatcher Instance { get ; internal set ; }
29
-
30
28
public static MatchResult FuzzySearch ( string query , string stringToCompare )
31
29
{
32
- return Instance . FuzzyMatch ( query , stringToCompare ) ;
30
+ return Ioc . Default . GetRequiredService < StringMatcher > ( ) . FuzzyMatch ( query , stringToCompare ) ;
33
31
}
34
32
35
33
public MatchResult FuzzyMatch ( string query , string stringToCompare )
Original file line number Diff line number Diff line change 3
3
using System . Drawing ;
4
4
using System . Text . Json . Serialization ;
5
5
using System . Windows ;
6
+ using CommunityToolkit . Mvvm . DependencyInjection ;
6
7
using Flow . Launcher . Infrastructure . Hotkey ;
7
8
using Flow . Launcher . Infrastructure . Storage ;
8
9
using Flow . Launcher . Plugin ;
@@ -14,12 +15,18 @@ namespace Flow.Launcher.Infrastructure.UserSettings
14
15
public class Settings : BaseModel , IHotkeySettings
15
16
{
16
17
private FlowLauncherJsonStorage < Settings > _storage ;
18
+ private StringMatcher _stringMatcher = null ;
17
19
18
- public void Initialize ( FlowLauncherJsonStorage < Settings > storage )
20
+ public void SetStorage ( FlowLauncherJsonStorage < Settings > storage )
19
21
{
20
22
_storage = storage ;
21
23
}
22
24
25
+ public void Initialize ( )
26
+ {
27
+ _stringMatcher = Ioc . Default . GetRequiredService < StringMatcher > ( ) ;
28
+ }
29
+
23
30
public void Save ( )
24
31
{
25
32
_storage . Save ( ) ;
@@ -192,7 +199,6 @@ public CustomBrowserViewModel CustomBrowser
192
199
}
193
200
} ;
194
201
195
-
196
202
/// <summary>
197
203
/// when false Alphabet static service will always return empty results
198
204
/// </summary>
@@ -210,8 +216,8 @@ public SearchPrecisionScore QuerySearchPrecision
210
216
set
211
217
{
212
218
_querySearchPrecision = value ;
213
- if ( StringMatcher . Instance != null )
214
- StringMatcher . Instance . UserSettingSearchPrecision = value ;
219
+ if ( _stringMatcher != null )
220
+ _stringMatcher . UserSettingSearchPrecision = value ;
215
221
}
216
222
}
217
223
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ public App()
37
37
// Initialize settings
38
38
var storage = new FlowLauncherJsonStorage < Settings > ( ) ;
39
39
_settings = storage . Load ( ) ;
40
- _settings . Initialize ( storage ) ;
40
+ _settings . SetStorage ( storage ) ;
41
41
_settings . WMPInstalled = WindowsMediaPlayerHelper . IsWindowsMediaPlayerInstalled ( ) ;
42
42
43
43
// Configure the dependency injection container
@@ -55,8 +55,9 @@ public App()
55
55
) . Build ( ) ;
56
56
Ioc . Default . ConfigureServices ( host . Services ) ;
57
57
58
- // Initialize the public API first
58
+ // Initialize the public API and Settings first
59
59
API = Ioc . Default . GetRequiredService < IPublicAPI > ( ) ;
60
+ _settings . Initialize ( ) ;
60
61
}
61
62
62
63
[ STAThread ]
@@ -90,9 +91,7 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
90
91
91
92
AbstractPluginEnvironment . PreStartPluginExecutablePathUpdate ( _settings ) ;
92
93
93
- var stringMatcher = Ioc . Default . GetRequiredService < StringMatcher > ( ) ;
94
- StringMatcher . Instance = stringMatcher ;
95
- stringMatcher . UserSettingSearchPrecision = _settings . QuerySearchPrecision ;
94
+ Ioc . Default . GetRequiredService < StringMatcher > ( ) . UserSettingSearchPrecision = _settings . QuerySearchPrecision ;
96
95
97
96
InternationalizationManager . Instance . Settings = _settings ;
98
97
InternationalizationManager . Instance . ChangeLanguage ( _settings . Language ) ;
You can’t perform that action at this time.
0 commit comments