We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents d824028 + ba42313 commit 2bbf954Copy full SHA for 2bbf954
src/Framework/Core/Controls/Options/PagingOptions.cs
@@ -107,8 +107,10 @@ public virtual IList<int> GetNearPageIndexes()
107
/// </summary>
108
protected virtual IList<int> GetDefaultNearPageIndexes(int distance)
109
{
110
- var firstIndex = Math.Max(PageIndex - distance, 0);
111
- var lastIndex = Math.Min(PageIndex + distance + 1, PagesCount);
+ var count = this.PagesCount;
+ var index = Math.Max(0, Math.Min(count - 1, PageIndex)); // clamp index to be a valid page
112
+ var firstIndex = Math.Max(index - distance, 0);
113
+ var lastIndex = Math.Min(index + distance + 1, count);
114
return Enumerable
115
.Range(firstIndex, lastIndex - firstIndex)
116
.ToList();
0 commit comments