diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index f918dcead..ce07dc0ea 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -5,6 +5,7 @@ using System.Drawing; using System.Text.Json.Serialization; using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedModels; +using Flow.Launcher; using Flow.Launcher.ViewModel; namespace Flow.Launcher.Infrastructure.UserSettings @@ -41,7 +42,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings public int CustomExplorerIndex { get; set; } = 0; public CustomExplorerViewModel CustomExplorer { - get => CustomExplorerList[CustomExplorerIndex]; + get => CustomExplorerList[CustomExplorerIndex < CustomExplorerList.Count ? CustomExplorerIndex : 0]; set => CustomExplorerList[CustomExplorerIndex] = value; } diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 5fc3f2fc9..16e4be8a0 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -56,7 +56,7 @@ namespace Flow.Launcher _viewModel.Save(); e.Cancel = true; await PluginManager.DisposePluginsAsync(); - Application.Current.Shutdown(); + Environment.Exit(0); } private void OnInitialized(object sender, EventArgs e) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 92e22f753..547228ee3 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -281,7 +281,7 @@ namespace Flow.Launcher.ViewModel ReloadPluginDataCommand = new RelayCommand(_ => { Hide(); - + PluginManager .ReloadData() .ContinueWith(_ => @@ -323,7 +323,7 @@ namespace Flow.Launcher.ViewModel /// public void ChangeQueryText(string queryText, bool reQuery = false) { - if (QueryText!=queryText) + if (QueryText != queryText) { // re-query is done in QueryText's setter method QueryText = queryText; @@ -706,7 +706,7 @@ namespace Flow.Launcher.ViewModel OpenResultCommandModifiers = _settings.OpenResultModifiers ?? DefaultOpenResultModifiers; } - public async void ToggleFlowLauncher() + public void ToggleFlowLauncher() { if (MainWindowVisibility != Visibility.Visible) { @@ -714,33 +714,30 @@ namespace Flow.Launcher.ViewModel } else { - switch (_settings.LastQueryMode) - { - case LastQueryMode.Empty: - ChangeQueryText(string.Empty); - Application.Current.MainWindow.Opacity = 0; // Trick for no delay - await Task.Delay(100); - Application.Current.MainWindow.Opacity = 1; - break; - case LastQueryMode.Preserved: - LastQuerySelected = true; - break; - case LastQueryMode.Selected: - LastQuerySelected = false; - break; - default: - throw new ArgumentException($"wrong LastQueryMode: <{_settings.LastQueryMode}>"); - } - MainWindowVisibility = Visibility.Collapsed; + Hide(); } } - public void Hide() + public async void Hide() { - if (MainWindowVisibility != Visibility.Collapsed) + switch (_settings.LastQueryMode) { - ToggleFlowLauncher(); + case LastQueryMode.Empty: + ChangeQueryText(string.Empty); + Application.Current.MainWindow.Opacity = 0; // Trick for no delay + await Task.Delay(100); + Application.Current.MainWindow.Opacity = 1; + break; + case LastQueryMode.Preserved: + LastQuerySelected = true; + break; + case LastQueryMode.Selected: + LastQuerySelected = false; + break; + default: + throw new ArgumentException($"wrong LastQueryMode: <{_settings.LastQueryMode}>"); } + MainWindowVisibility = Visibility.Collapsed; } #endregion