diff options
Diffstat (limited to 'core/edit.zig')
| -rw-r--r-- | core/edit.zig | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/core/edit.zig b/core/edit.zig index f3a87e57..70b765cc 100644 --- a/core/edit.zig +++ b/core/edit.zig @@ -427,8 +427,13 @@ pub var drawing = false; /// A terminal's rows as text (`Term.rows`), kept for one pane until its /// grid moves. Returned slices remain valid until the next cache rebuild -/// or reset. +/// or reset. A replica's rollback copy holds it as any state: its text and +/// rows are made whole and freed whole, never written, so the copy pins +/// them (blobs, freed raw) and puts the cache back with the core: no +/// emulator is written while a copy is held (replica.zig `confirm`: a unit +/// that writes one lets the copy go or is applied after it is put back). pub const RowsCache = struct { + pub const replica = .{ .blob = .{ "text", "rows", "text_alloc" } }; /// whose grid this describes; null = the slot is free pane: ?*const Pane = null, /// the rows joined by '\n' — `flatSurface` hands this back verbatim @@ -442,8 +447,8 @@ pub const RowsCache = struct { stale: bool = false, pub fn reset(c: *RowsCache, gpa: std.mem.Allocator) void { - if (c.text_alloc.len > 0) gpa.free(c.text_alloc); - if (c.rows.len > 0) gpa.free(c.rows); + pardes.memory.freeRaw(gpa, c.text_alloc); + pardes.memory.freeRaw(gpa, c.rows); c.* = .{}; } @@ -470,7 +475,6 @@ const empty_grid = [1][]const u8{""}; /// in `Pardes.shell_rows` while its grid holds still. pub fn shellRows(p: *Pardes, pane: *Pane) ![]const []const u8 { const state = pane.terminal orelse return &empty_grid; - pardes.tape.touchTerminal(); const c = &p.shell_rows; if (!c.stale and c.pane == pane) return c.rows; // Another pane's rows, or a dropped pane's still waiting for the step's |
