summaryrefslogtreecommitdiff
path: root/core/File.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/File.zig')
-rw-r--r--core/File.zig15
1 files changed, 12 insertions, 3 deletions
diff --git a/core/File.zig b/core/File.zig
index 36e014b3..fdf57fdf 100644
--- a/core/File.zig
+++ b/core/File.zig
@@ -122,6 +122,11 @@ pub const State = struct {
/// Its file was deleted on disk: said once (`deleted`) until it is
/// written or found again.
disk_gone: bool = false,
+ /// Its text was read from, or written to, a file of this host's disk
+ /// at its path (not the served tree's, nor a name never saved): what
+ /// Recent keeps (Pardes.onDisk), learned where that read or write ran,
+ /// so a close asks the disk nothing.
+ on_disk: bool = false,
/// A +Pager pane (`pardes -`): no line numbers, its program's colours
/// through Filter until it is toggled off.
pager: bool = false,
@@ -572,7 +577,7 @@ pub fn open(p: *Pardes, id: usize, path: []const u8, line: usize) !*Pane {
errdefer p.gpa.free(content);
const total = lineCount(content);
const scroll: usize = if (line > 0 and line <= total) line - 1 else 0;
- pane.file = .{ .path = path_copy, .content = content, .scroll = scroll, .history = history };
+ pane.file = .{ .path = path_copy, .content = content, .scroll = scroll, .history = history, .on_disk = filesystem.localPath(path) != null };
pane.body.cur_pinned = true;
pane.body.cur_row = @intCast(scroll);
p.installPane(id, pane);
@@ -959,7 +964,7 @@ pub fn zerox(p: *Pardes, from: usize, to: usize) !*Pane {
if (f.twin == 0) {
const group = try p.gpa.dupe(u8, f.path);
errdefer p.gpa.free(group);
- try p.twin_groups.append(p.gpa, .{ .id = p.next_twin, .saved_revision = f.saved_revision, .saved_hash = f.saved_hash, .saved_len = f.saved_len, .disk_newer = f.disk_newer, .disk_gone = f.disk_gone, .path = group });
+ try p.twin_groups.append(p.gpa, .{ .id = p.next_twin, .saved_revision = f.saved_revision, .saved_hash = f.saved_hash, .saved_len = f.saved_len, .disk_newer = f.disk_newer, .disk_gone = f.disk_gone, .on_disk = f.on_disk, .path = group });
f.twin = p.next_twin;
p.next_twin +%= 1;
}
@@ -977,6 +982,7 @@ pub fn zerox(p: *Pardes, from: usize, to: usize) !*Pane {
.saved_len = f.saved_len,
.disk_newer = f.disk_newer,
.disk_gone = f.disk_gone,
+ .on_disk = f.on_disk,
.mtime = f.mtime,
.scroll = f.scroll,
.tree_context = f.tree_context,
@@ -1019,6 +1025,7 @@ pub const TwinGroup = struct {
saved_len: ?usize,
disk_newer: ?u64,
disk_gone: bool,
+ on_disk: bool,
path: []u8,
};
@@ -1050,7 +1057,7 @@ pub fn syncTwins(p: *Pardes) void {
}
for (members[0..n]) |f| {
if (f.saved_revision == group.saved_revision and f.saved_hash == group.saved_hash and f.saved_len == group.saved_len and
- f.disk_newer == group.disk_newer and f.disk_gone == group.disk_gone and std.mem.eql(u8, f.path, group.path)) continue;
+ f.disk_newer == group.disk_newer and f.disk_gone == group.disk_gone and f.on_disk == group.on_disk and std.mem.eql(u8, f.path, group.path)) continue;
// This one changed: the group, and every other twin, take it.
if (!std.mem.eql(u8, f.path, group.path)) {
const path = p.gpa.dupe(u8, f.path) catch break;
@@ -1062,6 +1069,7 @@ pub fn syncTwins(p: *Pardes) void {
group.saved_len = f.saved_len;
group.disk_newer = f.disk_newer;
group.disk_gone = f.disk_gone;
+ group.on_disk = f.on_disk;
for (members[0..n], member_panes[0..n]) |other, other_pane| {
if (other == f) continue;
other.saved_revision = f.saved_revision;
@@ -1069,6 +1077,7 @@ pub fn syncTwins(p: *Pardes) void {
other.saved_len = f.saved_len;
other.disk_newer = f.disk_newer;
other.disk_gone = f.disk_gone;
+ other.on_disk = f.on_disk;
if (!std.mem.eql(u8, other.path, f.path)) {
const path = p.gpa.dupe(u8, f.path) catch continue;
p.gpa.free(other.path);