summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 21:40:57 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commit45609211f5047b5aec9964807cd5c98242cc70d7 (patch)
tree8093bccf27e3e0f10d2c268ea03800c74e18602d /src/pardes.zig
parent30cda150dff03bb1ca7e50f4b79a04775ea7a98d (diff)
downloadpardes-45609211f5047b5aec9964807cd5c98242cc70d7.tar.gz
pardes-45609211f5047b5aec9964807cd5c98242cc70d7.zip
A session restored from a dump is built as a fresh one is: its column and workspace tags take several selections, and its 9P files have a time
dump.initDump copied Pardes.init's construction and had drifted from it: it never gave the column and workspace tags their allocator, so after -l or Restore they could not hold more than one selection, and never set fs.started, so every 9P mtime read 0. Pardes.create is now the one construction, allocators, tags, the tree's clock and the mounts, that init and initDump both start from. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 623af3c9..3ecc80ae 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -4594,16 +4594,18 @@ pub const Pardes = struct {
/// `p.executeBuiltinLine(...)`; it lives with the rest of exec in exec.zig.
pub const executeBuiltinLine = exec.executeBuiltinLine;
- pub fn init(gpa: std.mem.Allocator, opts: Options) !*Pardes {
- const image_gpa = opts.image_allocator orelse gpa;
- const pdf_gpa = opts.pdf_allocator orelse gpa;
- const tree_sitter_gpa = opts.tree_sitter_allocator orelse gpa;
+ /// The one construction of a session, empty: its allocators, its column
+ /// and workspace tags, the 9P tree's clock and its mounts. `init` boots
+ /// a layout into it and a dump's restore (dump.initDump) its panes; a
+ /// second copy of this drifted once, leaving restored tags without an
+ /// allocator and every 9P mtime 0.
+ pub fn create(gpa: std.mem.Allocator, opts: Options) !*Pardes {
const p = try gpa.create(Pardes);
p.* = .{
.gpa = gpa,
- .image_gpa = image_gpa,
- .pdf_gpa = pdf_gpa,
- .tree_sitter_gpa = tree_sitter_gpa,
+ .image_gpa = opts.image_allocator orelse gpa,
+ .pdf_gpa = opts.pdf_allocator orelse gpa,
+ .tree_sitter_gpa = opts.tree_sitter_allocator orelse gpa,
.opts = opts,
.col_tags = @splat(.{ .what = .column, .gpa = gpa }),
.global_tag = .{ .what = .workspace, .gpa = gpa },
@@ -4618,6 +4620,12 @@ pub const Pardes = struct {
p.fs.started = ctlfs.events.now();
for (opts.mounts) |mount| try p.fs.mount(gpa, mount.name, mount.dial);
p.opts.mounts = &.{};
+ return p;
+ }
+
+ pub fn init(gpa: std.mem.Allocator, opts: Options) !*Pardes {
+ const p = try create(gpa, opts);
+ errdefer p.deinit();
p.boot = Boot.of(opts);
switch (p.boot) {
.document => {