summaryrefslogtreecommitdiff
path: root/core/edit_cmd.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-25 14:21:49 -0300
committerGabriel Schneider <[email protected]>2026-11-25 14:49:19 -0300
commit46d061dd4650449ba3b30b0c6023aca251e94ebd (patch)
tree3de1531e3efdbea7f93476d286054395add4d25b /core/edit_cmd.zig
parente6c384833912598d65c509f0d3a7b713fab0a8eb (diff)
downloadpardes-46d061dd4650449ba3b30b0c6023aca251e94ebd.tar.gz
pardes-46d061dd4650449ba3b30b0c6023aca251e94ebd.zip
edit_cmd: an Edit's change holds the reading pane it changes, as a typed one does (pick-ui SPEC §6.5, "Editing a reading pane keeps it"): a sam Edit puts its new text in by File.load, which holds no pane (it is Get's and a reread's too, which are not edits), so after `Edit 3a/…/` in a pane that was only read, a Look from it stepped that pane to the other file in place and closed the edited one (Trail.show, deinitPane): its unsaved change gone from every pane, without a word; found by D1's triage of the install gate's plain row (test/daemon.py far: the session's Edit, then its Look); RUN (TEST FIRST): edit_cmd.zig "an Edit's change holds the reading pane it changes, ..." fails on walkui-final (e6c384833912) at edit_cmd.zig:824, the pane still reading after the Edit, and with that line skipped at :830, the notes' pane gone (stepped to big.txt); THE FIX: Trail.edited after the Edit's File.load, as lsp/Ask.zig does after a server's edit; a user could have hit it: any Edit (`Edit ,s/a/b/g`, `X/…/`) in a reading pane, then a Look, a `g d` or a list's Enter from it; core-test filtered 11/11
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/edit_cmd.zig')
-rw-r--r--core/edit_cmd.zig30
1 files changed, 30 insertions, 0 deletions
diff --git a/core/edit_cmd.zig b/core/edit_cmd.zig
index 8fbde726..7efa98bc 100644
--- a/core/edit_cmd.zig
+++ b/core/edit_cmd.zig
@@ -417,6 +417,10 @@ fn commit(p: *Pardes, pd: *Pending, outputs: []const []const u8) void {
return p.reportError(.at(at), "Edit", err);
};
panes.File.load(p, pf, new);
+ // An edit, though made as a new text: a reading pane it
+ // changes is held (pick-ui SPEC §6.5), or a jump from it
+ // would step it off its unsaved text.
+ pardes.Trail.edited(p, pf);
}
}
if (ops.len > 0 or f.moved) ninep_pane.setFileDot(p.settings.tab, pane, sam.moveDot(f.dot, ops));
@@ -803,3 +807,29 @@ test "e and r say a file that cannot be read as Get says it" {
try testing.expect(std.mem.indexOf(u8, r.reply.ename, c[1]) != null);
}
}
+
+test "an Edit's change holds the reading pane it changes, as a typed one does: a Look from it after opens its reader, and the change stays in it" {
+ var tmp = testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.writeFile(testing.io, .{ .sub_path = "notes.txt", .data = "one\ntwo\nthree\n" });
+ try tmp.dir.writeFile(testing.io, .{ .sub_path = "big.txt", .data = "big\n" });
+ var dir_buf: [4096]u8 = undefined;
+ const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)];
+ const p = try th.withFile(testing.allocator, "scratch\n");
+ defer p.deinit();
+ p.settings.jumps = .walk;
+ var path: [4200]u8 = undefined;
+ // The notes in a reading pane (the first walked to them).
+ look.lookAt(p, 0, try std.fmt.bufPrint(&path, "{s}/notes.txt", .{dir}));
+ const notes = p.view().active;
+ try testing.expect(pardes.Trail.reading(p, p.panes[notes].?));
+ try testing.expectEqual(tree.Status.ok, th.wr(p, tree.Node.of(p.panes[notes].?.serial, .ctl), "Edit 3a/ an edit/\n").reply.status);
+ try testing.expectEqualStrings("one\ntwo\nthree\n an edit", p.panes[notes].?.file.?.content);
+ try testing.expect(!pardes.Trail.reading(p, p.panes[notes].?));
+ // A Look from it: its reader, under it; the notes and their change kept.
+ look.lookAt(p, notes, try std.fmt.bufPrint(&path, "{s}/big.txt", .{dir}));
+ const reader = p.view().active;
+ try testing.expect(reader != notes);
+ try testing.expectEqualStrings("big.txt", std.Io.Dir.path.basename(p.panes[reader].?.file.?.path));
+ try testing.expectEqualStrings("one\ntwo\nthree\n an edit", p.panes[notes].?.file.?.content);
+}