From 9bd34ae2afdb05713f312e7e58dc3d516ea84ebe Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 30 Oct 2026 19:37:42 -0300 Subject: Query: a +Search's rows recoloured are made again (locations.cloneRows, Query.save's copy), never written in place: the rows are a blob (File.State location_rows), whose word a digest keeps by address and a replica's rollback copy pins, so a release session kept the word of their colours before a paint landed (recolor's @memcpy); an edit moved them into dropped_marks with the stale word, a replica that hashed them at another time diverged there (fixer 1's soak: `pane 5.file.dropped_marks`), and a client loading the session's dump hashed the colours it carried and loaded "as another session"; dropped_marks stays in the digest, as an undo back to its text reads it; Stream's test, which a Debug build fails before (`the 82-byte blob ... is not what its kept word was: written in place`) Co-Authored-By: Claude Opus 5.5 --- src/locations.zig | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/locations.zig') diff --git a/src/locations.zig b/src/locations.zig index 40f22f85..d0904607 100644 --- a/src/locations.zig +++ b/src/locations.zig @@ -36,6 +36,30 @@ pub fn freeRows(gpa: std.mem.Allocator, rows: []Row) void { freeRaw(gpa, rows); } +/// A copy of `rows` and all they own, gpa's: rows are a blob (File.State +/// `location_rows`), made again rather than written. +pub fn cloneRows(gpa: std.mem.Allocator, rows: []const Row) ![]Row { + const out = try gpa.alloc(Row, rows.len); + var made: usize = 0; + errdefer { + for (out[0..made]) |r| { + gpa.free(r.path); + gpa.free(r.colors); + } + gpa.free(out); + } + for (rows, out) |r, *o| { + o.* = r; + o.path = try gpa.dupe(u8, r.path); + o.colors = gpa.dupe(u8, r.colors) catch |err| { + gpa.free(o.path); + return err; + }; + made += 1; + } + return out; +} + /// A list of rows being built, given up: each row's own bytes, then the list. pub fn freeRowList(gpa: std.mem.Allocator, rows: *std.ArrayList(Row)) void { for (rows.items) |row| { -- cgit v1.3