summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
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 => {