summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ninep/ctl.zig11
-rw-r--r--src/ninep/events.zig8
-rw-r--r--src/pardes.zig5
3 files changed, 22 insertions, 2 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index fdc83da8..10336e38 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -1633,6 +1633,17 @@ test "get reloads the pane from disk and reports a missing file without losing d
try testing.expect(pane_files.dirtyOf(pane));
}
+test "Save path of a file pane logs a save record naming that path" {
+ const p = try withFile(testing.allocator, "one\n");
+ defer p.deinit();
+ const serial = serialOf(p);
+ const saved = wr(p, Node.of(serial, .ctl), "Save /tmp/pardes-save-copy.txt\n");
+ try testing.expectEqual(Status.ok, saved.reply.status);
+ p.perform(.{ .save_text = .{ .pane = 0, .serial = serial, .path = Pardes.SavePath.from("/tmp/pardes-save-copy.txt") } });
+ var want: [64]u8 = undefined;
+ try testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "save {d} /tmp/pardes-save-copy.txt\n", .{serial})));
+}
+
test "exec Save writes the named file through the host" {
const gpa = testing.allocator;
const p = try withFile(gpa, "one\ntwo\n");
diff --git a/src/ninep/events.zig b/src/ninep/events.zig
index fa90fe71..a09f7278 100644
--- a/src/ninep/events.zig
+++ b/src/ninep/events.zig
@@ -160,10 +160,16 @@ pub fn noteLog(p: *Pardes, kind: LogKind, pane: *Pane) void {
if (kind == .rename) return;
announce(p);
}
+ noteLogAs(p, kind, pane, pane_files.nameOf(p, pane));
+}
+
+/// noteLog naming `path` rather than the pane's name: a `Save path` that
+/// writes a copy elsewhere is `save <serial> <path>`.
+pub fn noteLogAs(p: *Pardes, kind: LogKind, pane: *Pane, path: []const u8) void {
var buf: [4 * 4096 + 64]u8 = undefined;
var name_buf: [4 * 4096]u8 = undefined;
// As /index shows it: a newline in the name is `\n`.
- const name = shown(pane_files.nameOf(p, pane), &name_buf);
+ const name = shown(path, &name_buf);
pushLog(p, std.fmt.bufPrint(&buf, "{s} {d} {s}\n", .{ @tagName(kind), pane.serial, name }) catch return);
}
diff --git a/src/pardes.zig b/src/pardes.zig
index 8c6ad5bb..f08cf01b 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -5606,14 +5606,17 @@ pub const Pardes = struct {
g.saved_revision = was;
return;
}
- if (st.promote) p.promoteSaved(st.pane, st.path.slice());
+ if (st.promote) p.promoteSaved(st.pane, st.path.slice()) else ctlfs.events.noteLogAs(p, .save, after, st.path.slice());
return;
}
if (!pane.isTerminal()) return;
const text = panes.terminal.screenTextAlloc(pane, p.gpa) catch return;
defer p.gpa.free(text);
makeParents(st.path.slice());
+ const failures = p.fs.failures;
p.hostWriteFile(st.pane, st.path.slice(), text);
+ if (p.fs.failures == failures) if (p.panes[st.pane]) |still| if (still.serial == st.serial)
+ ctlfs.events.noteLogAs(p, .save, still, st.path.slice());
},
.write_dump => {
const out = p.dump_out orelse return;