Skip to content

Commit

Permalink
Check enumerator index (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
drasticactions authored Mar 5, 2025
1 parent c8100e1 commit 86f6553
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/FishyFlip/ATObjectCollectionAsyncEnumerator{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,16 @@ public async ValueTask<bool> MoveNextAsync()
if (this.Collection.HasMoreItems)
{
await this.Collection.GetMoreItemsAsync(cancellationToken: this.cancellationToken);
this.index++;
return true;

// Need to verify that new items were added with GetMoreItemsAsync to increase the index,
// otherwise it will throw on an out of range index.
if (this.index + 1 < this.Collection.Count)
{
this.index++;
return true;
}

return this.Collection.HasMoreItems;
}

return false;
Expand Down

0 comments on commit 86f6553

Please sign in to comment.