From 83aada2056a5668a984f0345908487857acfae9a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 10 Jul 2026 07:20:56 -0700 Subject: [PATCH] terminal/search: preserve serial order in reverse matches Reverse multi-page highlight construction reordered node and row- bound columns but left captured page generations in their original order. Every cross-page result therefore paired each node with another page generation and could be rejected as stale despite remaining live. Reverse the serial column with the other flattened chunk metadata and cover the node-plus-generation pairing in the existing boundary match test. --- src/terminal/search/sliding_window.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/terminal/search/sliding_window.zig b/src/terminal/search/sliding_window.zig index 5c29ce03b..2f858ec85 100644 --- a/src/terminal/search/sliding_window.zig +++ b/src/terminal/search/sliding_window.zig @@ -489,12 +489,14 @@ pub const SlidingWindow = struct { .reverse => { const slice = self.chunk_buf.slice(); const nodes = slice.items(.node); + const serials = slice.items(.serial); const starts = slice.items(.start); const ends = slice.items(.end); if (self.chunk_buf.len > 1) { // Reverse all our chunks. This should be pretty obvious why. std.mem.reverse(*PageList.List.Node, nodes); + std.mem.reverse(u64, serials); std.mem.reverse(size.CellCountInt, starts); std.mem.reverse(size.CellCountInt, ends); @@ -1447,6 +1449,15 @@ test "SlidingWindow two pages match across boundary reversed" { // Search should find a match { const h = w.next().?; + const chunks = h.chunks.slice(); + const nodes = chunks.items(.node); + const serials = chunks.items(.serial); + try testing.expectEqual(2, chunks.len); + try testing.expectEqual(node, nodes[0]); + try testing.expectEqual(node.serial, serials[0]); + try testing.expectEqual(node.next.?, nodes[1]); + try testing.expectEqual(node.next.?.serial, serials[1]); + const sel = h.untracked(); try testing.expectEqual(point.Point{ .active = .{ .x = 76,