diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-29 20:14:31 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-29 21:13:33 -0300 |
| commit | 22a482a9f1d73472e646b4a83b55bafd9528f5a3 (patch) | |
| tree | 0144c8eb191bfade8c40de02809ed81d720d6bb3 /src/dump.zig | |
| parent | d8e30740463dda5a87fb8a4f6e9755fbb84b7220 (diff) | |
| download | pardes-22a482a9f1d73472e646b4a83b55bafd9528f5a3.tar.gz pardes-22a482a9f1d73472e646b4a83b55bafd9528f5a3.zip | |
dump: savePane puts back only the fields it changes, not a copy of the whole 88 KB pane, and makes its empty undo history only for a slim record; the notes say what the small close after a big one measures
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/dump.zig')
| -rw-r--r-- | src/dump.zig | 32 |
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); } |
