Skip to content

Commit

Permalink
Fix : InMemoryRecordRepository was not clearing Bookends properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pressacco committed Dec 11, 2024
1 parent 18d69c4 commit dea0372
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions Src/BlueDotBrigade.Weevil.Core/Data/InMemoryRecordRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,26 @@ private static IList<IRecord> ClearUnselected(ImmutableArray<IRecord> records, I

private static IList<IRecord> ClearBeyondBookends(ImmutableArray<IRecord> allRecords, ImmutableArray<Bookend> bookends)
{
var filteredRecords = new List<IRecord>();

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<IRecord>();

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

Expand All @@ -232,7 +241,8 @@ public ImmutableArray<IRecord> Get(int maxRecords)

try
{
if (_selectedRecords.Length == 0)
// Early exit?
if (_selectedRecords.Length == 0 && _clearOperation != ClearOperation.BeyondBookends)
{
visibleRecords = _allRecords;
}
Expand Down

0 comments on commit dea0372

Please sign in to comment.