diff --git a/src/Views/ChangeCollectionView.axaml.cs b/src/Views/ChangeCollectionView.axaml.cs index 07623696..5d0694c0 100644 --- a/src/Views/ChangeCollectionView.axaml.cs +++ b/src/Views/ChangeCollectionView.axaml.cs @@ -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 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; } }