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.
This commit is contained in:
Mitchell Hashimoto
2026-07-10 07:20:56 -07:00
parent 91a63e5287
commit 83aada2056

View File

@@ -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,