diff --git a/Terminal.Gui/Views/TreeView.cs b/Terminal.Gui/Views/TreeView.cs index 4acb41dc8..d1526f456 100644 --- a/Terminal.Gui/Views/TreeView.cs +++ b/Terminal.Gui/Views/TreeView.cs @@ -1082,7 +1082,7 @@ namespace Terminal.Gui { public Branch Origin {get;} - private HashSet> alsoIncluded = new HashSet>(); + private HashSet included = new HashSet(); /// /// Creates a new selection between two branches in the tree @@ -1093,6 +1093,8 @@ namespace Terminal.Gui { public TreeSelection(Branch from, int toIndex, Branch[] map ) { Origin = from; + included.Add(Origin.Model); + var oldIdx = Array.IndexOf(map,from); var lowIndex = Math.Min(oldIdx,toIndex); @@ -1100,15 +1102,13 @@ namespace Terminal.Gui { // Select everything between the old and new indexes foreach(var alsoInclude in map.Skip(lowIndex).Take(highIndex-lowIndex)){ - alsoIncluded.Add(alsoInclude); + included.Add(alsoInclude.Model); } } public bool Contains(T model) { - return - Equals(Origin.Model,model) || - alsoIncluded.Any(b=>Equals(b.Model,model)); + return included.Contains(model); } }