diff --git a/Flow.Launcher/ViewModel/SelectBrowserViewModel.cs b/Flow.Launcher/ViewModel/SelectBrowserViewModel.cs index 537263fcf..12f43d752 100644 --- a/Flow.Launcher/ViewModel/SelectBrowserViewModel.cs +++ b/Flow.Launcher/ViewModel/SelectBrowserViewModel.cs @@ -53,6 +53,11 @@ public partial class SelectBrowserViewModel : BaseModel [RelayCommand] private void Delete() { - CustomBrowsers.RemoveAt(SelectedCustomBrowserIndex--); + var currentIndex = SelectedCustomBrowserIndex; + if (currentIndex >= 0 && currentIndex < CustomBrowsers.Count) + { + CustomBrowsers.RemoveAt(currentIndex); + SelectedCustomBrowserIndex = currentIndex > 0 ? currentIndex - 1 : 0; + } } } diff --git a/Flow.Launcher/ViewModel/SelectFileManagerViewModel.cs b/Flow.Launcher/ViewModel/SelectFileManagerViewModel.cs index ee7da9e0f..253f74b47 100644 --- a/Flow.Launcher/ViewModel/SelectFileManagerViewModel.cs +++ b/Flow.Launcher/ViewModel/SelectFileManagerViewModel.cs @@ -3,14 +3,10 @@ using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Linq; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; using CommunityToolkit.Mvvm.Input; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; -using ModernWpf.Controls; namespace Flow.Launcher.ViewModel; @@ -115,6 +111,11 @@ public partial class SelectFileManagerViewModel : BaseModel [RelayCommand] private void Delete() { - CustomExplorers.RemoveAt(SelectedCustomExplorerIndex--); + var currentIndex = SelectedCustomExplorerIndex; + if (currentIndex >= 0 && currentIndex < CustomExplorers.Count) + { + CustomExplorers.RemoveAt(currentIndex); + SelectedCustomExplorerIndex = currentIndex > 0 ? currentIndex - 1 : 0; + } } }