summaryrefslogtreecommitdiff
path: root/core/dump.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 02:44:13 -0300
committerGabriel Schneider <[email protected]>2026-11-24 04:07:49 -0300
commitf0f2a5125fd4b034ebcd424afd4a55c3185191ab (patch)
tree1f1267a1331c42137678af580b8428a966e0b5bc /core/dump.zig
parented05c825102ebce7cd1e314226a1c88b8658baef (diff)
downloadpardes-f0f2a5125fd4b034ebcd424afd4a55c3185191ab.tar.gz
pardes-f0f2a5125fd4b034ebcd424afd4a55c3185191ab.zip
layout: a view's geometry (`rects`, `col_x`, `col_w`) is the layout pass's, never dumped: every load lays each open view out again (dump.zig `afterLoad`: `layout.compute` per open view, as a resize lays it out), and `cols` is held to `ncol` (`View.replica.len`): RUN FIRST on pardes-merge67 (core/fuzz.zig's dump fuzz, the restore road's seed 589): an image's pane 0 rect read back as 534 rows on a 24-row screen (`View.rects`, dumped as it was), drawn: draw.zig:448 `clearRect`, then surface.zig:322's `at` asserted; walk.zig `pastHeld` passes over a pair whose buffer is derived; TEST FIRST: dump.zig "a view's geometry is laid out again at a load, never read: a pane's rect past its screen in a dump is the layout's after it" (merge67: expected 22, found 534); not whole alone: the dump's layout moved, and the fuzz's seeds then reach the indexes the next change holds (`live` past the views, a file's top past its text)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/dump.zig')
-rw-r--r--core/dump.zig28
1 files changed, 28 insertions, 0 deletions
diff --git a/core/dump.zig b/core/dump.zig
index deb18dba..10d36350 100644
--- a/core/dump.zig
+++ b/core/dump.zig
@@ -143,6 +143,14 @@ pub fn dumpExit(p: *Pardes) !void {
/// view showed in a dump made before the layer's lines were the buffer's
/// (wire 31 and older: a view's bit, no lines), its lines in it (jj.loaded).
fn afterLoad(p: *Pardes) void {
+ // Each view laid out again over its columns and its screen, as a resize
+ // lays it out: its geometry is derived, never read (View.replica).
+ const live = p.live;
+ for (p.views, 0..) |slot, k| if (slot != null) {
+ p.live = @intCast(k);
+ layout.compute(p);
+ };
+ p.live = live;
for (p.panes) |slot| if (slot) |pane| if (pane.file) |*f| {
const text = pardes.panes.File.fileText(f, p.scratch.allocator()) catch continue;
f.context.reload(p.tree_sitter_gpa, f.path, text, f.revision);
@@ -1024,6 +1032,26 @@ test "a dump keeps the session's settings, and a restore applies them" {
try std.testing.expect(!restored.settings.wrap);
}
+test "a view's geometry is laid out again at a load, never read: a pane's rect past its screen in a dump is the layout's after it" {
+ // The fuzz's restore road, seed 589: an image whose pane 0 said 534
+ // rows on a 24-row screen, drawn: surface.zig's `at` asserted.
+ const gpa = std.testing.allocator;
+ const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 });
+ defer p.deinit();
+ const want = p.view().rects[0];
+ p.view().rects[0].h = 534;
+ p.view().col_w[0] = 900;
+ const dumped = try dumpBytes(p);
+ defer gpa.free(dumped);
+ p.view().rects[0] = want;
+ const q = try load(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }, dumped, null);
+ defer q.deinit();
+ try std.testing.expectEqual(want, q.view().rects[0]);
+ try std.testing.expectEqual(@as(u16, 80), q.view().col_w[0]);
+ _ = q.frame_arena.reset(.retain_capacity);
+ _ = try q.render(q.frame_arena.allocator());
+}
+
test "a session with every column it may hold dumps and restores them all" {
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 1200, .rows = 24 });