mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix potential issue with index boundary in Delete command
This commit is contained in:
parent
5578daaa3e
commit
45b81811f7
2 changed files with 12 additions and 6 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue