diff options
Diffstat (limited to 'core/dump.zig')
| -rw-r--r-- | core/dump.zig | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/core/dump.zig b/core/dump.zig index 1616f557..eb0ef263 100644 --- a/core/dump.zig +++ b/core/dump.zig @@ -261,7 +261,9 @@ pub fn image(p: *Pardes, name: []const u8) ![]u8 { /// first delta brings each afresh). What is left is the session's mutable /// state, made in its step. pub fn dumpJoin(p: *Pardes, deferred: *std.ArrayListUnmanaged(walk.Deferred)) ![]u8 { - slim_terminals = true; + // Under bytes, each terminal whole (as the join's step reloaded it on + // every side: panes.reloadTerminals), its sequence in flight with it. + slim_terminals = p.tape.screen_state; defer slim_terminals = false; // The join's file reads are the session's host's, between its steps: // with its io, which the core's tape holds (a walk's hook takes no more). @@ -270,7 +272,8 @@ pub fn dumpJoin(p: *Pardes, deferred: *std.ArrayListUnmanaged(walk.Deferred)) ![ return dumpWith(p, deferred); } -/// `dumpJoin`'s and `dumpExit`'s: a terminal dumps its size, not its emulator. +/// `dumpJoin`'s under screen state and `dumpExit`'s: a terminal dumps its +/// size, not its emulator. pub var slim_terminals = false; /// `dumpJoin`'s: a plain kind's pane carries its file (SlotRecord.file), /// read with this io. @@ -406,6 +409,7 @@ fn loadKnowing(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, notes: for (others) |o| gpa.free(o.panes); gpa.free(others); l.shared.shrinkRetainingCapacity(at); + for (p.panes) |slot| if (slot) |pane| if (pane.file) |*f| f.context.reload(p.tree_sitter_gpa, f.path, f.content, f.revision); p.readSessionFacts(); return p; } @@ -491,6 +495,7 @@ fn loadImage(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, notes: ?* try views.undumpedOld(p, others, gpa); } l.made.shrinkRetainingCapacity(at); + for (p.panes) |slot| if (slot) |pane| if (pane.file) |*f| f.context.reload(p.tree_sitter_gpa, f.path, f.content, f.revision); p.readSessionFacts(); return p; } @@ -708,11 +713,11 @@ pub fn savePane(gpa: std.mem.Allocator, pane: *pardes.panes.Pane, slim: bool) ![ // The fields it changes put back after, not the whole pane (88 KB) kept // aside: a store record is made at every close. const cwd = pane.cwd; - const attached_to = pane.attached_to; + const docked_to = pane.docked_to; const terminal = pane.terminal; defer { pane.cwd = cwd; - pane.attached_to = attached_to; + pane.docked_to = docked_to; pane.terminal = terminal; } if (cwd == .inherited) { @@ -720,7 +725,7 @@ pub fn savePane(gpa: std.mem.Allocator, pane: *pardes.panes.Pane, slim: bool) ![ const dir = pane.cwdSlice(); pane.cwd = .{ .owned = @constCast(dir) }; } - pane.attached_to = null; + pane.docked_to = null; if (!slim) return walk.save(pardes.panes.Pane, gpa, pane); pane.terminal = null; const f = if (pane.file) |*file| file else return walk.save(pardes.panes.Pane, gpa, pane); @@ -985,7 +990,7 @@ test "a session with every column it may hold dumps and restores them all" { } test "a restored session's column and workspace tags take more than one selection, and its 9P files have a time" { - const th = @import("ninep/testing.zig"); + const th = @import("ninep/harness.zig"); const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true }); defer p.deinit(); @@ -1037,7 +1042,7 @@ test "a pane restored with unsaved text is asked about by Exit, Restore, Del and const id = for (restored.panes, 0..) |slot, i| { if (slot) |candidate| if (candidate.file != null and candidate.file.?.output == null) break i; } else return error.FileLost; - const th = @import("ninep/testing.zig"); + const th = @import("ninep/harness.zig"); const node = if (word == .Del or word == .get) ctlfs.Node.of(restored.panes[id].?.serial, .ctl) else @@ -1171,7 +1176,7 @@ test "a session's byte dump read by name, field by field as another build reads test "an old dump's file, a byte dump, is read by -l and by a Restore of its path, for one release" { const gpa = std.testing.allocator; - const th = @import("ninep/testing.zig"); + const th = @import("ninep/harness.zig"); const p = try Pardes.init(gpa, .{ .tty_only = true }); defer p.deinit(); _ = try p.setTestFile("kept in a .dump\n"); @@ -1200,7 +1205,7 @@ test "an old dump's file, a byte dump, is read by -l and by a Restore of its pat try std.testing.expectEqualSlices(u8, bytes, again); } -test "restored syntax context caches are rebuilt rather than loaded with the core allocator" { +test "restored syntax context caches are rebuilt from the text rather than loaded with the core allocator" { const gpa = std.testing.allocator; var syntax_gpa: std.heap.DebugAllocator(.{}) = .init; defer std.testing.expect(syntax_gpa.deinit() == .ok) catch @panic("syntax allocator leaked"); @@ -1237,9 +1242,13 @@ test "restored syntax context caches are rebuilt rather than loaded with the cor defer gpa.free(bytes); const q = try load(gpa, opts, bytes, null); defer q.deinit(); + // This build's: the revision kept, the declarations parsed again from + // the text, with the syntax allocator. + const want = try pardes.syntax.contextDeclarations(syntax_gpa.allocator(), f.path, f.content); + defer syntax_gpa.allocator().free(want); for (q.panes) |slot| if (slot) |restored| if (restored.file) |file| { - try std.testing.expectEqual(@as(usize, 0), file.context.declarations.len); - try std.testing.expectEqual(@as(?u32, null), file.context.revision); + try std.testing.expectEqual(f.context.revision, file.context.revision); + try std.testing.expectEqualSlices(pardes.syntax.ContextDeclaration, want, file.context.declarations); }; } |
