diff --git a/Src/BlueDotBrigade.Weevil.Core/Data/InMemoryRecordRepository.cs b/Src/BlueDotBrigade.Weevil.Core/Data/InMemoryRecordRepository.cs index e0f58e5..669133d 100644 --- a/Src/BlueDotBrigade.Weevil.Core/Data/InMemoryRecordRepository.cs +++ b/Src/BlueDotBrigade.Weevil.Core/Data/InMemoryRecordRepository.cs @@ -199,17 +199,26 @@ private static IList ClearUnselected(ImmutableArray records, I private static IList ClearBeyondBookends(ImmutableArray allRecords, ImmutableArray bookends) { - var filteredRecords = new List(); - - foreach (Bookend bookend in bookends) + // Have any regions of interest been defined? + // ... If not, then return everything. + if (bookends.Length == 0) { - // Add all records that fall within the current region of interest - filteredRecords.AddRange(allRecords.Where(record => - record.LineNumber >= bookend.Minimum.LineNumber && - record.LineNumber <= bookend.Maximum.LineNumber)); + return allRecords; } + else + { + var filteredRecords = new List(); + + foreach (Bookend bookend in bookends) + { + // Add all records that fall within the current region of interest + filteredRecords.AddRange(allRecords.Where(record => + record.LineNumber >= bookend.Minimum.LineNumber && + record.LineNumber <= bookend.Maximum.LineNumber)); + } - return filteredRecords; + return filteredRecords; + } } #endregion @@ -232,7 +241,8 @@ public ImmutableArray Get(int maxRecords) try { - if (_selectedRecords.Length == 0) + // Early exit? + if (_selectedRecords.Length == 0 && _clearOperation != ClearOperation.BeyondBookends) { visibleRecords = _allRecords; }