diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-29 05:29:45 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:16 -0300 |
| commit | 24729dbbf8b32966a3f33c9bc20599b185856dd3 (patch) | |
| tree | f5c0632b49a61b27334c42ab5ad0fdb74df35821 /src/File.zig | |
| parent | eba47199a51370c9753798fbd2439a85ddc4e5bb (diff) | |
| download | pardes-24729dbbf8b32966a3f33c9bc20599b185856dd3.tar.gz pardes-24729dbbf8b32966a3f33c9bc20599b185856dd3.zip | |
get and a deleted file say what happened: the path, changed <serial> deleted, reloaded
get on a file gone from disk failed with a bare ENOENT; it now says get:
<path>: no such file. A watched file deleted on disk was silent; the pane
keeps its text and says <file> deleted on disk (Save writes it again)
once, logged changed <serial> deleted (only a path the watch has read: a
pane renamed to a name never on disk is not deleted). A get that throws a
dirty buffer's
state away logs changed <serial> reloaded, as the watch's reload does.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/File.zig')
| -rw-r--r-- | src/File.zig | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/File.zig b/src/File.zig index 17399d8b..5f6d7097 100644 --- a/src/File.zig +++ b/src/File.zig @@ -64,6 +64,9 @@ pub const State = struct { /// Put does (exec.c:577, "modified since last read"). disk_newer: ?u64 = null, disk_newer_warned: bool = false, + /// Its file was deleted on disk: said once (`deleted`) until it is + /// written or found again. + disk_gone: bool = false, /// Seconds of the last content change, for the filesystem's stat; zero until edited. mtime: u32 = 0, /// Non-null for a generated output buffer rather than an on-disk file. @@ -970,6 +973,20 @@ pub fn redo(p: *Pardes, pane: *Pane) void { restoreSnap(pane, f, next); } +/// A pane's file deleted on disk: the text stays, and it says so once, +/// `<file> deleted on disk (Save writes it again)`, logged `changed +/// <serial> deleted`. +pub fn deleted(p: *Pardes, id: u8) void { + const pane = p.panes[id] orelse return; + const f = if (pane.file) |*file| file else return; + if (f.disk_gone) return; + f.disk_gone = true; + var said: [limits.host_path_cap + 64]u8 = undefined; + p.setMessage(id, std.fmt.bufPrint(&said, "{s} deleted on disk (Save writes it again)", .{f.path}) catch "deleted on disk (Save writes it again)"); + var rec: [32]u8 = undefined; + pardes.ctlfs.events.notePath(p, "changed", std.fmt.bufPrint(&rec, "{d} deleted", .{pane.serial}) catch ""); +} + /// A file rewritten on disk. A clean buffer takes the new text, committed /// onto the same undo history as typed edits. A buffer with unsaved edits /// is never reloaded under them: it keeps its text and stays dirty, and @@ -981,6 +998,7 @@ pub fn redo(p: *Pardes, pane: *Pane) void { pub fn changed(p: *Pardes, id: u8, bytes: []const u8) void { const pane = p.panes[id] orelse return; const f = if (pane.file) |*file| file else return; + f.disk_gone = false; if (std.mem.eql(u8, f.content, bytes)) return; if (f.saved_hash) |saved| if (f.revision != f.saved_revision and std.hash.Wyhash.hash(0, f.content) != saved) { const disk = std.hash.Wyhash.hash(0, bytes); |
