Skip to content

Commit 1d8a8a6

Browse files
NeWbY100claude
andcommitted
fix: Prev/Next responsiveness and scroll-into-view in hex search
Two fixes affecting the Prev button: 1. HexSearcher.FindBackward had an infinite loop when the search reached chunkStart=0 with no valid match: chunkEnd was advanced to `chunkStart + overlap` which on a zero start yields `overlap`, the same value as the previous iteration. Break out once we've processed the chunk anchored at offset 0. 2. HexViewControl.OnSelectionOffsetChanged only invalidated visuals without scrolling. The auto-scroll path was wired to SelectionLength only, so Next/Prev with an unchanged pattern length never scrolled the match into view. Route both setters through OnSelectionChanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1fcafa5 commit 1d8a8a6

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

ReScene.NET/Controls/HexViewControl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ private static void OnSelectionOffsetChanged(DependencyObject d, DependencyPrope
128128
if (d is HexViewControl c)
129129
{
130130
c._canvas.ClearMouseSelection();
131-
c._canvas.InvalidateVisual();
131+
c.OnSelectionChanged();
132132
}
133133
}
134134

ReScene.NET/Services/HexSearcher.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ public static long FindBackward(IHexDataSource source, HexSearchPattern pattern,
156156
}
157157
}
158158

159+
// When we've already scanned from the start, every preceding byte is covered;
160+
// continuing would re-read the same overlap region forever.
161+
if (chunkStart == 0)
162+
{
163+
break;
164+
}
165+
159166
chunkEnd = chunkStart + overlap;
160167
}
161168

0 commit comments

Comments
 (0)