summaryrefslogtreecommitdiff
path: root/src/dump.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-29 18:04:38 -0300
committerGabriel Schneider <[email protected]>2026-10-29 21:13:33 -0300
commit7ba57610929544bf3d1b3d0bf65dbb039d97942b (patch)
tree3cfa59be7b0b56e82b8bff80856eaa7f1cf63b53 /src/dump.zig
parent70de5ec5ff3dad01afcc45244ad5e5a481486da6 (diff)
downloadpardes-7ba57610929544bf3d1b3d0bf65dbb039d97942b.tar.gz
pardes-7ba57610929544bf3d1b3d0bf65dbb039d97942b.zip
snapshots: dump, load, restore, tagnav and headersweep-restored show the session as it was dumped: a terminal's view, its prompts hidden in text mode, a pane's message, typed text over its history
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/dump.zig')
-rw-r--r--src/dump.zig28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/dump.zig b/src/dump.zig
index ccbcd158..20299b79 100644
--- a/src/dump.zig
+++ b/src/dump.zig
@@ -331,7 +331,7 @@ fn loadAndRevive(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, previ
/// A loaded core given to this host (with `revivePane` for each of its
/// panes): the store and Recent read (a Restore's carried from the session
-/// it replaces), its ThemeFile asked for again, and the screen this host's.
+/// it replaces) and its ThemeFile asked for again.
fn reviveSession(p: *Pardes, previous: ?*const Pardes) !void {
if (previous) |old| {
// Never a serial or a request number the old session gave out.
@@ -358,9 +358,8 @@ fn reviveSession(p: *Pardes, previous: ?*const Pardes) !void {
for (p.panes) |slot| if (slot) |pane| {
pane.fs.unannounced = true;
};
- // This host's screen; the next sync lays the panes out on it.
- p.screen_w = p.opts.cols;
- p.screen_h = p.opts.rows;
+ // The dump's screen until this host says its own (a resize): two
+ // reflows would lose where a terminal's view was.
p.sync();
exec.applyStartupConfig(p);
colors.finishThemeInitialization(p);
@@ -569,3 +568,24 @@ test "a pane restored with unsaved text is asked about by Exit, Restore, Del and
try std.testing.expect(!restored.quit and restored.panes[id] != null);
}
}
+
+test "a loaded terminal's history stays above its banner, the cursor where it was" {
+ if (comptime !pardes.panes.terminal.enabled or isolated) return error.SkipZigTest;
+ const gpa = std.testing.allocator;
+ const term = pardes.panes.terminal;
+ const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 });
+ defer p.deinit();
+ while (p.nextEffect()) |_| {}
+ term.feedOutput(p, p.panes[0].?, "one\r\ntwo\r\n$ ");
+ const before = term.gridCursor(p.panes[0].?);
+ try dumpState(p);
+ const loaded = try load(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }, p.dump_out.?, null);
+ defer loaded.deinit();
+ try std.testing.expectEqual(before, term.gridCursor(loaded.panes[0].?));
+ const q = try initFromDump(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }, p.dump_out.?);
+ defer q.deinit();
+ const text = try term.screenTextAlloc(q.panes[0].?, gpa);
+ defer gpa.free(text);
+ try std.testing.expect(std.mem.indexOf(u8, text, "one\ntwo\n") != null);
+ try std.testing.expect(std.mem.indexOf(u8, text, "two") .? < std.mem.indexOf(u8, text, "restored history").?);
+}