diff --git a/dev/Repeater/APITests/SelectionModelTests.cs b/dev/Repeater/APITests/SelectionModelTests.cs index d6be4fd9de..14c19b74be 100644 --- a/dev/Repeater/APITests/SelectionModelTests.cs +++ b/dev/Repeater/APITests/SelectionModelTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. using MUXControlsTestApp.Utilities; @@ -940,21 +940,43 @@ public void SelectRangeRegressionTest() selectionModel.SelectRange(IndexPath.CreateFrom(0), IndexPath.CreateFrom(1, 1)); ValidateSelection(selectionModel, - new List() - { - Path(0, 0), - Path(0, 1), - Path(0, 2), - Path(0), - Path(1, 0), - Path(1, 1) - }, - new List() - { - Path(), - Path(1) - }, - 1 /* selectedInnerNodes */); + new List() + { + Path(0, 0), + Path(0, 1), + Path(0, 2), + Path(0), + Path(1, 0), + Path(1, 1) + }, + new List() + { + Path(), + Path(1) + }, + 1 /* selectedInnerNodes */); + + selectionModel = new SelectionModel() { Source = CreateNestedData(2, 2, 1) }; + + selectionModel.SelectRange( + Path(1), Path(2)); + + ValidateSelection( + selectionModel, + new List { + Path(1,0,0), + Path(1), Path(2), + Path(1,0),Path(1,1), + Path(2,0),Path(2,1), + Path(1,0,1), + Path(1,1,0),Path(1,1,1), + Path(2,0,0),Path(2,0,1), + Path(2,1,0),Path(2,1,1), + + }, + new List { IndexPath.CreateFromIndices(new List { }) }, + 12); + }); } diff --git a/dev/Repeater/SelectionTreeHelper.cpp b/dev/Repeater/SelectionTreeHelper.cpp index a2078184ec..e80961a673 100644 --- a/dev/Repeater/SelectionTreeHelper.cpp +++ b/dev/Repeater/SelectionTreeHelper.cpp @@ -84,8 +84,8 @@ void SelectionTreeHelper::TraverseRangeRealizeChildren( bool isStartPath = IsSubSet(start, currentPath); bool isEndPath = IsSubSet(end, currentPath); - int startIndex = depth < start.GetSize() && isStartPath ? start.GetAt(depth) : 0; - int endIndex = depth < end.GetSize() && isEndPath ? end.GetAt(depth) : node->DataCount() - 1; + int startIndex = depth < start.GetSize() && isStartPath ? std::max(0, start.GetAt(depth)) : 0; + int endIndex = depth < end.GetSize() && isEndPath ? std::min(node->DataCount() - 1, end.GetAt(depth)) : node->DataCount() - 1; for (int i = endIndex; i >= startIndex; i--) {