Fix `IndexOutOfRangeException` when trying to reverse a zero-length slider

This commit is contained in:
Pasi4K5 2023-08-14 14:09:08 +02:00
parent f42b3603b3
commit 55ac942e7a
1 changed files with 1 additions and 1 deletions

View File

@ -42,7 +42,7 @@ public static void Reverse(this SliderPath sliderPath, out Vector2 positionalOff
double[] distinctSegmentEnds = segmentEnds.Distinct().ToArray(); double[] distinctSegmentEnds = segmentEnds.Distinct().ToArray();
// Remove control points at the end which do not affect the visual slider path ("invisible" control points). // Remove control points at the end which do not affect the visual slider path ("invisible" control points).
if (Math.Abs(segmentEnds[^1] - segmentEnds[^2]) < 1e-10 && distinctSegmentEnds.Length > 1) if (segmentEnds.Length >= 2 && Math.Abs(segmentEnds[^1] - segmentEnds[^2]) < 1e-10 && distinctSegmentEnds.Length > 1)
{ {
int numVisibleSegments = distinctSegmentEnds.Length - 2; int numVisibleSegments = distinctSegmentEnds.Length - 2;
var nonInheritedControlPoints = controlPoints.Where(p => p.Type is not null).ToList(); var nonInheritedControlPoints = controlPoints.Where(p => p.Type is not null).ToList();