mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Remove instance for StringMatcher
This commit is contained in:
parent
39d34b1a03
commit
e022ad6acd
3 changed files with 15 additions and 12 deletions
|
|
@ -25,11 +25,9 @@ namespace Flow.Launcher.Infrastructure
|
|||
_alphabet = alphabet;
|
||||
}
|
||||
|
||||
public static StringMatcher Instance { get; internal set; }
|
||||
|
||||
public static MatchResult FuzzySearch(string query, string stringToCompare)
|
||||
{
|
||||
return Instance.FuzzyMatch(query, stringToCompare);
|
||||
return Ioc.Default.GetRequiredService<StringMatcher>().FuzzyMatch(query, stringToCompare);
|
||||
}
|
||||
|
||||
public MatchResult FuzzyMatch(string query, string stringToCompare)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections.ObjectModel;
|
|||
using System.Drawing;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Windows;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Infrastructure.Hotkey;
|
||||
using Flow.Launcher.Infrastructure.Storage;
|
||||
using Flow.Launcher.Plugin;
|
||||
|
|
@ -14,12 +15,18 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
public class Settings : BaseModel, IHotkeySettings
|
||||
{
|
||||
private FlowLauncherJsonStorage<Settings> _storage;
|
||||
private StringMatcher _stringMatcher = null;
|
||||
|
||||
public void Initialize(FlowLauncherJsonStorage<Settings> storage)
|
||||
public void SetStorage(FlowLauncherJsonStorage<Settings> storage)
|
||||
{
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_stringMatcher = Ioc.Default.GetRequiredService<StringMatcher>();
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
_storage.Save();
|
||||
|
|
@ -192,7 +199,6 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// when false Alphabet static service will always return empty results
|
||||
/// </summary>
|
||||
|
|
@ -210,8 +216,8 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
set
|
||||
{
|
||||
_querySearchPrecision = value;
|
||||
if (StringMatcher.Instance != null)
|
||||
StringMatcher.Instance.UserSettingSearchPrecision = value;
|
||||
if (_stringMatcher != null)
|
||||
_stringMatcher.UserSettingSearchPrecision = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace Flow.Launcher
|
|||
// Initialize settings
|
||||
var storage = new FlowLauncherJsonStorage<Settings>();
|
||||
_settings = storage.Load();
|
||||
_settings.Initialize(storage);
|
||||
_settings.SetStorage(storage);
|
||||
_settings.WMPInstalled = WindowsMediaPlayerHelper.IsWindowsMediaPlayerInstalled();
|
||||
|
||||
// Configure the dependency injection container
|
||||
|
|
@ -55,8 +55,9 @@ namespace Flow.Launcher
|
|||
).Build();
|
||||
Ioc.Default.ConfigureServices(host.Services);
|
||||
|
||||
// Initialize the public API first
|
||||
// Initialize the public API and Settings first
|
||||
API = Ioc.Default.GetRequiredService<IPublicAPI>();
|
||||
_settings.Initialize();
|
||||
}
|
||||
|
||||
[STAThread]
|
||||
|
|
@ -90,9 +91,7 @@ namespace Flow.Launcher
|
|||
|
||||
AbstractPluginEnvironment.PreStartPluginExecutablePathUpdate(_settings);
|
||||
|
||||
var stringMatcher = Ioc.Default.GetRequiredService<StringMatcher>();
|
||||
StringMatcher.Instance = stringMatcher;
|
||||
stringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision;
|
||||
Ioc.Default.GetRequiredService<StringMatcher>().UserSettingSearchPrecision = _settings.QuerySearchPrecision;
|
||||
|
||||
InternationalizationManager.Instance.Settings = _settings;
|
||||
InternationalizationManager.Instance.ChangeLanguage(_settings.Language);
|
||||
|
|
|
|||
Loading…
Reference in a new issue