mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
enhance: only change the selected changes if it is necessary
This commit is contained in:
parent
2c0a58a99b
commit
e432559a5e
1 changed files with 31 additions and 9 deletions
|
@ -116,9 +116,7 @@ namespace SourceGit.Views
|
|||
foreach (var c in model.SelectedItems)
|
||||
CollectChangesInNode(selected, c);
|
||||
|
||||
_isSelecting = true;
|
||||
SetCurrentValue(SelectedChangesProperty, selected);
|
||||
_isSelecting = false;
|
||||
TrySetSelected(selected);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -144,9 +142,7 @@ namespace SourceGit.Views
|
|||
foreach (var c in model.SelectedItems)
|
||||
selected.Add(c);
|
||||
|
||||
_isSelecting = true;
|
||||
SetCurrentValue(SelectedChangesProperty, selected);
|
||||
_isSelecting = false;
|
||||
TrySetSelected(selected);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -172,9 +168,7 @@ namespace SourceGit.Views
|
|||
foreach (var c in model.SelectedItems)
|
||||
selected.Add(c);
|
||||
|
||||
_isSelecting = true;
|
||||
SetCurrentValue(SelectedChangesProperty, selected);
|
||||
_isSelecting = false;
|
||||
TrySetSelected(selected);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -269,6 +263,34 @@ namespace SourceGit.Views
|
|||
}
|
||||
}
|
||||
|
||||
private void TrySetSelected(List<Models.Change> changes)
|
||||
{
|
||||
var old = SelectedChanges;
|
||||
|
||||
if (old == null && changes.Count == 0)
|
||||
return;
|
||||
|
||||
if (old != null && old.Count == changes.Count)
|
||||
{
|
||||
bool allEquals = true;
|
||||
foreach (var c in old)
|
||||
{
|
||||
if (!changes.Contains(c))
|
||||
{
|
||||
allEquals = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (allEquals)
|
||||
return;
|
||||
}
|
||||
|
||||
_isSelecting = true;
|
||||
SetCurrentValue(SelectedChangesProperty, changes);
|
||||
_isSelecting = false;
|
||||
}
|
||||
|
||||
private bool _isSelecting = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue