Skip to content

Conversation

@belucha
Copy link

@belucha belucha commented Jan 25, 2026

closes #15

This was failing, as the newSegment was extended by the old one, but the Memory still references the original segment!

This was failing, as the newSegment was extended by the old one,
but the Memory still references the original segment!
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes RawMemory.TryAddSegment so that when a new segment is prepended (and therefore extended to include) an existing segment, the Segments list is updated to reference the combined segment (closing #15).

Changes:

  • Replaces the previous Any(...)-based extension check with an indexed loop so the list entry can be updated when newSegment absorbs an existing segment.
  • Keeps the existing behavior of rejecting overlaps and sorting only when a truly new segment is added.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 21 to 24
if (Segments.Any((s) => s.Overlaps(newSegment)))
{
return false;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's simplify the overall logic, and reduce to a single loop, move this check into your for loop please.

@benedekkupper
Copy link
Member

Hi @belucha, thanks for your contribution! May I ask how you stumbled upon this bug, being the first to face this issue?

@belucha
Copy link
Author

belucha commented Jan 25, 2026

I merged several hex files with e.g. separate version records created separately, then merging somehow failed...
It's that simple!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RawMemory.TryAddSegment fails, when the new segment is prepended to an existing segment

2 participants