diff --git a/Flow.Launcher.Infrastructure/StringMatcher.cs b/Flow.Launcher.Infrastructure/StringMatcher.cs index 55aa0a1ec..2707308d5 100644 --- a/Flow.Launcher.Infrastructure/StringMatcher.cs +++ b/Flow.Launcher.Infrastructure/StringMatcher.cs @@ -3,6 +3,7 @@ using Flow.Launcher.Plugin.SharedModels; using System; using System.Collections.Generic; using System.Linq; +using Flow.Launcher.Infrastructure.UserSettings; namespace Flow.Launcher.Infrastructure { @@ -14,15 +15,11 @@ namespace Flow.Launcher.Infrastructure private readonly IAlphabet _alphabet; - public StringMatcher() - { - _alphabet = Ioc.Default.GetRequiredService(); - } - // This is a workaround to allow unit tests to set the instance - public StringMatcher(IAlphabet alphabet) + public StringMatcher(IAlphabet alphabet, Settings settings) { _alphabet = alphabet; + UserSettingSearchPrecision = settings.QuerySearchPrecision; } public static MatchResult FuzzySearch(string query, string stringToCompare) diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 48007e995..952ca70c4 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -91,8 +91,6 @@ namespace Flow.Launcher AbstractPluginEnvironment.PreStartPluginExecutablePathUpdate(_settings); - Ioc.Default.GetRequiredService().UserSettingSearchPrecision = _settings.QuerySearchPrecision; - // TODO: Clean InternationalizationManager.Instance and InternationalizationManager.Instance.GetTranslation in future InternationalizationManager.Instance.ChangeLanguage(_settings.Language); diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 6123a93d9..528f54172 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -247,7 +247,7 @@ namespace Flow.Launcher public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null) { using var explorer = new Process(); - var explorerInfo = _settingsVM.Settings.CustomExplorer; + var explorerInfo = _settingsVM._settings.CustomExplorer; explorer.StartInfo = new ProcessStartInfo { @@ -268,7 +268,7 @@ namespace Flow.Launcher { if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps) { - var browserInfo = _settingsVM.Settings.CustomBrowser; + var browserInfo = _settingsVM._settings.CustomBrowser; var path = browserInfo.Path == "*" ? "" : browserInfo.Path; diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 8b15150cf..f87194c30 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -27,7 +27,7 @@ public partial class SettingWindow public SettingWindow() { var viewModel = Ioc.Default.GetRequiredService(); - _settings = viewModel.Settings; + _settings = Ioc.Default.GetRequiredService(); DataContext = viewModel; _viewModel = viewModel; _updater = Ioc.Default.GetRequiredService(); diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 37276a1ad..0a1968d9d 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -6,11 +6,11 @@ namespace Flow.Launcher.ViewModel; public partial class SettingWindowViewModel : BaseModel { - public Settings Settings { get; init; } + public readonly Settings _settings; - public SettingWindowViewModel() + public SettingWindowViewModel(Settings settings) { - Settings = Ioc.Default.GetRequiredService(); + _settings = settings; } /// @@ -18,30 +18,30 @@ public partial class SettingWindowViewModel : BaseModel /// public void Save() { - Settings.Save(); + _settings.Save(); } public double SettingWindowWidth { - get => Settings.SettingWindowWidth; - set => Settings.SettingWindowWidth = value; + get => _settings.SettingWindowWidth; + set => _settings.SettingWindowWidth = value; } public double SettingWindowHeight { - get => Settings.SettingWindowHeight; - set => Settings.SettingWindowHeight = value; + get => _settings.SettingWindowHeight; + set => _settings.SettingWindowHeight = value; } public double? SettingWindowTop { - get => Settings.SettingWindowTop; - set => Settings.SettingWindowTop = value; + get => _settings.SettingWindowTop; + set => _settings.SettingWindowTop = value; } public double? SettingWindowLeft { - get => Settings.SettingWindowLeft; - set => Settings.SettingWindowLeft = value; + get => _settings.SettingWindowLeft; + set => _settings.SettingWindowLeft = value; } }