Skip to content

Commit

Permalink
Fix updating count in IndexRange.
Browse files Browse the repository at this point in the history
With failing-then-passing unit test.
  • Loading branch information
grokys committed May 12, 2023
1 parent 1f033b4 commit 9f9ed62
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/Avalonia.Controls.TreeDataGrid/Selection/IndexRanges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public void Add(in IndexPath index)
_ranges.Add(parent, ranges);
}

IndexRange.Add(ranges, new IndexRange(index[^1]));
++Count;
Count += IndexRange.Add(ranges, new IndexRange(index[^1]));
}

public void Add(in IndexPath parent, in IndexRange range)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,20 @@ public void Selecting_Already_Selected_Item_Doesnt_Raise_SelectionChanged()

Assert.Equal(0, raised);
}

[Fact]
public void Selecting_Item_Twice_Results_In_Correct_Count()
{
var target = CreateTarget();

using (target.BatchUpdate())
{
target.SelectedIndex = new IndexPath(1);
target.Select(new IndexPath(1));
}

Assert.Equal(1, target.Count);
}
}

public class Deselect
Expand Down

0 comments on commit 9f9ed62

Please sign in to comment.