summaryrefslogtreecommitdiff
path: root/src/dump.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/dump.zig')
-rw-r--r--src/dump.zig32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/dump.zig b/src/dump.zig
index e6a41f09..2cef46e2 100644
--- a/src/dump.zig
+++ b/src/dump.zig
@@ -457,22 +457,34 @@ fn revivePane(p: *Pardes, id: usize, pane: *pardes.panes.Pane, was_on_disk: bool
/// file's text, which is read from its file again (a store's record past
/// its bound).
pub fn savePane(gpa: std.mem.Allocator, pane: *pardes.panes.Pane, slim: bool) ![]u8 {
- const was = pane.*;
- defer pane.* = was;
- if (was.cwd == .inherited) {
+ // 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 terminal = pane.terminal;
+ defer {
+ pane.cwd = cwd;
+ pane.attached_to = attached_to;
+ pane.terminal = terminal;
+ }
+ if (cwd == .inherited) {
// Read before the union is written (its tag is set first).
const dir = pane.cwdSlice();
pane.cwd = .{ .owned = @constCast(dir) };
}
pane.attached_to = null;
- var empty: pardes.panes.File.History = .{};
- if (slim) {
- pane.terminal = null;
- if (pane.file) |*f| {
- f.history = ∅
- if (f.output == null and f.revision == f.saved_revision and filesystem.localPath(f.path) != null) f.content = &.{};
- }
+ 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);
+ const history = f.history;
+ const content = f.content;
+ defer {
+ f.history = history;
+ f.content = content;
}
+ var empty: pardes.panes.File.History = .{};
+ f.history = ∅
+ if (f.output == null and f.revision == f.saved_revision and filesystem.localPath(f.path) != null) f.content = &.{};
return walk.save(pardes.panes.Pane, gpa, pane);
}