diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 16:12:18 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 16:23:31 -0300 |
| commit | e4bda7e899089b0c8594ad1b03099402bddeeef1 (patch) | |
| tree | 2972000d9c446cf51088b610610105fa5430a082 /core/replica.zig | |
| parent | d3f9f3775e2efbcb4d617afb4a18eaf5efa72e29 (diff) | |
| download | pardes-e4bda7e899089b0c8594ad1b03099402bddeeef1.tar.gz pardes-e4bda7e899089b0c8594ad1b03099402bddeeef1.zip | |
Query rows: what a step asks a worker to paint no longer hangs on the colours this process happens to have: the bytes soak's 'the core called search where the tape has a host' (g6, seed 5 at 80 ms, the witness parting at the session's own step) was a query row's colours read by the step that decides whether to ask a worker for its file's paint (Stream.paintRows, an effect on the tape): Query.writePlacesRows (Query.zig:1073) took a `/` row's colours from the owner's frame paint (File.highlights, painted by refreshHighlights, derived) and only a row left plain went to Shades.of, which asked; Shades.of asked only on a miss in the locations cache (derived: a dump carries none, so a client joined since has none); recolor asked only for rows whose colours were still zeros (derived); so a session that had drawn its owner, or had the file's colours from an earlier paint, asked nothing where a replica that never draws, or a client joined since, asked a worker (and its stream.rows_count, rows_paint, rows_asked, rows_asked_at moved on one side only: the four fields the witness named); FIRST the tests (core/replica.zig, a session whose host paints on workers): 'a client joined from a dump asks a worker for a `/` query's colours as the session does, though only the session has drawn its owner' and '... though only the session has them from an earlier paint', both on the base 'diverged: the core called search where the tape has a done (0)'; then the fix: Shades asks for every file its rows show (Shades.file at every row, whatever colours it has; Shades.done at the file's end and each walk's), paintRows decides on replicated state alone (the row ring, the pending paint, the pane's text), its key the path's hash (a file is painted once between two Greps, not again at each revision of an open text, which a frame paints where it is seen); a row's colours still come from the frame's paint and the cache, out of the rows' digest as before; root.zig's kept_out lines for highlights and locations_cache say so
Diffstat (limited to 'core/replica.zig')
| -rw-r--r-- | core/replica.zig | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/core/replica.zig b/core/replica.zig index 24d1ad21..e05cf79e 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -5560,6 +5560,70 @@ test "a client joined from a dump makes a `/` query's rows as the session does, } } +// A query row's colours come from what this process has (its frames' +// paint of the owner, File.highlights; a worker's paint kept in the +// locations cache): out of the rows' digest. Whether a step asks a +// worker to paint the rows' file (Stream.paintRows, an effect on the +// tape) must not come from them: a session whose host paints on workers +// (search), that has drawn its owner, and a client that has not. +test "a client joined from a dump asks a worker for a `/` query's colours as the session does, though only the session has drawn its owner" { + const Paints = struct { + fn search(_: ?*anyopaque, _: u32) void {} + const vtable: pardes.Host.VTable = .{ .watched = TestHost.watched, .search = search }; + }; + const gpa = std.testing.allocator; + // A view as tall as the text: the frame paints every line of it. + const a = try Authority.init(gpa, .{ .cols = 80, .rows = 500, .file = "build.zig" }, .{ .vtable = &Paints.vtable }, false); + defer a.deinit(); + { + const was = Stepping.begin(&a.t, null); + defer was.end(); + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + _ = try a.core.render(arena.allocator()); + } + _ = try a.openView(2); + const joiner = try joinedNow(a, 3, 1); + defer joiner.deinit(); + var buf: [256]u8 = undefined; + for ("/co", 1..) |c, seq| { + const u = try gpa.dupe(u8, try a.take(try inputOf(&buf, 1, @intCast(seq), .{ .key = .{ .cp = c, .text = &.{c} } }))); + defer gpa.free(u); + joiner.confirm(u); + try agrees(a, joiner); + } +} + +// The same for the colours a worker painted earlier, kept in the session's +// locations cache (a Grep since has asked again of every file): a dump +// carries no cache, so a client joined since has none. +test "a client joined from a dump asks a worker for a `/` query's colours as the session does, though only the session has them from an earlier paint" { + const Paints = struct { + fn search(_: ?*anyopaque, _: u32) void {} + const vtable: pardes.Host.VTable = .{ .watched = TestHost.watched, .search = search }; + }; + const gpa = std.testing.allocator; + const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "build.zig" }, .{ .vtable = &Paints.vtable }, false); + defer a.deinit(); + { + const p = a.core; + const f = &p.panes[0].?.file.?; + const colors = try pardes.syntax.highlightFileRange(gpa, f.path, f.content, 0, f.content.len); + defer gpa.free(colors); + try p.locations_cache.put(p.tree_sitter_gpa, f.path, f.content, colors); + } + _ = try a.openView(2); + const joiner = try joinedNow(a, 3, 1); + defer joiner.deinit(); + var buf: [256]u8 = undefined; + for ("/co", 1..) |c, seq| { + const u = try gpa.dupe(u8, try a.take(try inputOf(&buf, 1, @intCast(seq), .{ .key = .{ .cp = c, .text = &.{c} } }))); + defer gpa.free(u); + joiner.confirm(u); + try agrees(a, joiner); + } +} + test "a step that reads a terminal's rows as the core keeps them sends a new client the ones it holds as holes" { if (pardes.Term.ops == null) return error.SkipZigTest; // a shell const gpa = std.testing.allocator; |
