diff options
Diffstat (limited to 'core/dump.zig')
| -rw-r--r-- | core/dump.zig | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/core/dump.zig b/core/dump.zig index d09f18c2..c0a84ffe 100644 --- a/core/dump.zig +++ b/core/dump.zig @@ -138,6 +138,18 @@ pub fn dumpExit(p: *Pardes) !void { try dumpState(p); } +/// What a load makes again of each file's pane: its declarations from the +/// file's text (the `Changes` layer's lines are none of it); and a layer a +/// view showed in a dump made before the layer's lines were the buffer's +/// (wire 31 and older: a view's bit, no lines), its lines in it (jj.loaded). +fn afterLoad(p: *Pardes) void { + for (p.panes) |slot| if (slot) |pane| if (pane.file) |*f| { + const text = pardes.panes.File.fileText(f, p.scratch.allocator()) catch continue; + f.context.reload(p.tree_sitter_gpa, f.path, text, f.revision); + }; + @import("jj.zig").loaded(p); +} + /// A file kept slim in a dump (`dumpExit`, a closed pane's past its bound, /// Store.zig): without its undo, and a clean file on disk without its /// text, which `revivePane` reads from its file again. @@ -151,7 +163,9 @@ const Slim = struct { fn take(f: *pardes.panes.File.State) Slim { const s: Slim = .{ .f = f, .history = f.history, .content = f.content }; f.history = ∅ - if (f.output == null and f.revision == f.saved_revision and filesystem.localPath(f.path) != null) f.content = &.{}; + // Not with the `Changes` layer's lines in it: the disk has the + // file's text, not the buffer. + if (f.output == null and f.revision == f.saved_revision and f.read_only.len == 0 and filesystem.localPath(f.path) != null) f.content = &.{}; return s; } @@ -440,7 +454,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); + afterLoad(p); p.readSessionFacts(); return p; } @@ -526,7 +540,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); + afterLoad(p); p.readSessionFacts(); return p; } |
