summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 08:00:41 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commitba0a0f82be43dde325012b3018b186bc808bdafc (patch)
treeb191c664840c11f8ab3a47c380a6a5f569ddb9b5 /src/exec.zig
parent0b359e1f99f1a2630969c1c00b6c71db3b794ccd (diff)
downloadpardes-ba0a0f82be43dde325012b3018b186bc808bdafc.tar.gz
pardes-ba0a0f82be43dde325012b3018b186bc808bdafc.zip
A Save whose write fails changes nothing: not the name, not the dirty flag
A scratch took its new name before the host wrote it, so `Save /root/x.txt` failing with EACCES renamed it anyway; a failed write to another name marked a clean file dirty. A scratch is now named once its write is done (promoteSaved), and a failed write puts the saved revision back. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/exec.zig')
-rw-r--r--src/exec.zig18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/exec.zig b/src/exec.zig
index 2b0c90cb..0bce67d2 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -301,17 +301,15 @@ pub fn saveTo(p: *Pardes, id: usize, path: []const u8) void {
if (pane.isTerminal()) askWrite(p, id, pane.serial, full);
return;
};
+ // A scratch takes the name once the write is done (promoteSaved): a
+ // Save that fails changes nothing, the name included.
if (f.output != null and panes.Output.fileTraits(f.output).saves) {
- const owned = p.gpa.dupe(u8, full) catch return;
- p.gpa.free(f.path);
- f.path = owned;
- f.output = null; // an ordinary file pane from here on
- f.watch_after_save = true;
- pane.clearCwd();
- // re-derive the tag as a plain file's
- if (pane.tag.own) |own| p.gpa.free(own);
- pane.tag.own = null;
- p.emit(.{ .save_file = .{ .pane = @intCast(id) } });
+ p.emit(.{ .save_text = .{
+ .pane = @intCast(id),
+ .serial = pane.serial,
+ .path = Pardes.SavePath.from(full),
+ .promote = true,
+ } });
return;
}
// its own path, spelled out: the in-place write, so the pane comes clean