diff --git a/src/ViewModels/BranchTreeNode.cs b/src/ViewModels/BranchTreeNode.cs index 63848b9f..a29e6a2c 100644 --- a/src/ViewModels/BranchTreeNode.cs +++ b/src/ViewModels/BranchTreeNode.cs @@ -16,6 +16,7 @@ namespace SourceGit.ViewModels public object Backend { get; private set; } = null; public int Depth { get; set; } = 0; public bool IsFiltered { get; set; } = false; + public bool IsSelected { get; set; } = false; public List Children { get; private set; } = new List(); public bool IsExpanded diff --git a/src/Views/BranchTree.axaml.cs b/src/Views/BranchTree.axaml.cs index deab507c..4fe4fce5 100644 --- a/src/Views/BranchTree.axaml.cs +++ b/src/Views/BranchTree.axaml.cs @@ -154,21 +154,24 @@ namespace SourceGit.Views if (selected == null || selected.Count == 0) return; - var set = new HashSet(); - foreach (var item in selected) + foreach (var item in e.AddedItems) { if (item is ViewModels.BranchTreeNode node) - set.Add(node); + node.IsSelected = true; + } + + foreach (var item in e.RemovedItems) + { + if (item is ViewModels.BranchTreeNode node) + node.IsSelected = false; } var prev = null as ViewModels.BranchTreeNode; - var isPrevSelected = false; foreach (var row in Rows) { - var isSelected = set.Contains(row); - if (isSelected) + if (row.IsSelected) { - if (isPrevSelected) + if (prev is { IsSelected: true }) { var prevTop = prev.CornerRadius.TopLeft; prev.CornerRadius = new CornerRadius(prevTop, 0); @@ -180,7 +183,6 @@ namespace SourceGit.Views } } - isPrevSelected = isSelected; prev = row; }