diff --git a/src/SIL.Machine/Corpora/ParallelTextCorpus.cs b/src/SIL.Machine/Corpora/ParallelTextCorpus.cs index 039329d1..2f8a4884 100644 --- a/src/SIL.Machine/Corpora/ParallelTextCorpus.cs +++ b/src/SIL.Machine/Corpora/ParallelTextCorpus.cs @@ -535,6 +535,7 @@ private class TargetCorpusEnumerator : DisposableBase, IEnumerator private readonly ScrVers _sourceVersification; private TextRow _current; private bool _isEnumerating = false; + private bool _enumeratorHasMoreData = true; public TargetCorpusEnumerator( IEnumerator enumerator, @@ -564,7 +565,7 @@ public bool MoveNext() _enumerator.MoveNext(); _isEnumerating = true; } - if (_verseRows.Count == 0 && _enumerator.Current != null) + if (_verseRows.Count == 0 && _enumerator.Current != null && _enumeratorHasMoreData) CollectVerses(); if (_verseRows.Count > 0) { @@ -575,15 +576,16 @@ public bool MoveNext() return false; } - bool result = _enumerator.MoveNext(); + _enumeratorHasMoreData = _enumerator.MoveNext(); _current = _enumerator.Current; - return result; + return _enumeratorHasMoreData; } public void Reset() { _enumerator.Reset(); _isEnumerating = false; + _enumeratorHasMoreData = true; } protected override void DisposeManagedResources() @@ -635,7 +637,8 @@ private void CollectVerses() if (!outOfOrder && scrRef.CompareTo(prevScrRef) < 0) outOfOrder = true; prevScrRef = scrRef; - } while (_enumerator.MoveNext()); + _enumeratorHasMoreData = _enumerator.MoveNext(); + } while (_enumeratorHasMoreData); if (outOfOrder) rowList.Sort((x, y) => x.Ref.CompareTo(y.Ref));