summaryrefslogtreecommitdiff
path: root/src/File.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/File.zig')
-rw-r--r--src/File.zig11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/File.zig b/src/File.zig
index b3c28290..eb11b0e4 100644
--- a/src/File.zig
+++ b/src/File.zig
@@ -84,6 +84,8 @@ pub const State = struct {
mtime: u32 = 0,
/// Non-null for a generated output buffer rather than an on-disk file.
output: ?Output.State = null,
+ /// A directory pane's entries (Dir.zig), its output `.dir`.
+ listing: ?panes.Dir.State = null,
mini: ?Mini.State = null,
scroll: usize = 0,
/// `line_starts[i]` is line i's byte offset. Empty means not built yet.
@@ -943,6 +945,14 @@ pub fn restore(p: *Pardes, id: usize, src: dump.Pane) !*Pane {
};
pane.cols = @max(1, src.cols);
pane.rows = @max(1, src.rows);
+ // A directory pane is its directory as it is now, laid out at the next
+ // sync; one that cannot be read keeps the text the dump kept.
+ if (output) |o| if (o.from == .dir) {
+ const f = &pane.file.?;
+ if (panes.Dir.read(p.gpa, panes.Dir.ofName(path))) |names| {
+ f.listing = .{ .names = names, .revision = f.revision };
+ } else |_| f.listing = .{ .names = &.{}, .revision = f.revision -% 1 };
+ };
if (output == null and filesystem.localPath(path) != null) p.emit(.{ .watch = .{ .pane = @intCast(id), .on = true, .mode = .baseline_disk } });
// Its file gone from disk since the dump: its text is nowhere else now,
// so it comes back as one deleted on disk, dirty, and Del, Exit and
@@ -984,6 +994,7 @@ pub fn deinit(p: *Pardes, pane: *Pane, file: *State) void {
};
p.gpa.free(file.path);
p.gpa.free(file.content);
+ if (file.listing) |listing| p.gpa.free(listing.names);
if (file.mini) |*mini| mini.deinit(p.gpa);
if (file.line_starts.len > 0) p.gpa.free(file.line_starts);
if (file.highlights.len > 0) p.tree_sitter_gpa.free(file.highlights);