optimize<WorkingCopyChanges>: run as stage/unstage all if all changes selected

This commit is contained in:
leo 2023-11-22 10:29:53 +08:00
parent cd934349aa
commit de75f5010b

View file

@ -371,7 +371,7 @@ namespace SourceGit.Views.Widgets {
private async void DoStage(List<string> files) { private async void DoStage(List<string> files) {
IsStaging = true; IsStaging = true;
Models.Watcher.SetEnabled(repo, false); Models.Watcher.SetEnabled(repo, false);
if (files == null || files.Count == 0) { if (files == null || files.Count == 0 || files.Count == Changes.Count) {
await Task.Run(() => new Commands.Add(repo).Exec()); await Task.Run(() => new Commands.Add(repo).Exec());
} else { } else {
for (int i = 0; i < files.Count; i += 10) { for (int i = 0; i < files.Count; i += 10) {
@ -709,7 +709,7 @@ namespace SourceGit.Views.Widgets {
#region STAGED #region STAGED
private async void DoUnstage(List<string> files) { private async void DoUnstage(List<string> files) {
Models.Watcher.SetEnabled(repo, false); Models.Watcher.SetEnabled(repo, false);
if (files == null || files.Count == 0) { if (files == null || files.Count == 0 || files.Count == Changes.Count) {
await Task.Run(() => new Commands.Reset(repo).Exec()); await Task.Run(() => new Commands.Reset(repo).Exec());
} else { } else {
for (int i = 0; i < files.Count; i += 10) { for (int i = 0; i < files.Count; i += 10) {