enhance: supports using Delete or Backspace to discard selected changes (#423)

This commit is contained in:
leo 2024-08-29 10:10:28 +08:00
parent 9c40b76577
commit c22ba75780
No known key found for this signature in database
5 changed files with 27 additions and 10 deletions

View file

@ -62,10 +62,21 @@ namespace SourceGit.Views
private void OnUnstagedKeyDown(object _, KeyEventArgs e)
{
if (DataContext is ViewModels.WorkingCopy vm && e.Key is Key.Space or Key.Enter)
if (DataContext is ViewModels.WorkingCopy vm)
{
vm.StageSelected();
e.Handled = true;
if (e.Key is Key.Space or Key.Enter)
{
vm.StageSelected();
e.Handled = true;
return;
}
if (e.Key is Key.Delete or Key.Back && vm.SelectedUnstaged is { Count: > 0 } selected)
{
vm.Discard(selected);
e.Handled = true;
return;
}
}
}