From 181170ff00a2019465b6401047407d9914b3b631 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 30 Sep 2026 19:38:59 -0300 Subject: An edit that changes nothing, an empty range deleted or a range replaced by what it holds, makes no undo step A shell's : > data on an empty address, echo abc > data over abc, or Edit s/d/d/ each pushed an undo step and a new revision, so Undo spent a press on nothing and the pane read as edited. The splice of the 9P writes and the Edit builtin now see the text is unchanged and stop. Co-Authored-By: Claude Opus 5.5 --- src/builtins.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/builtins.zig') diff --git a/src/builtins.zig b/src/builtins.zig index edeb7ac8..cb588ba3 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -1140,8 +1140,11 @@ pub const Edit = struct { } if (res.ops.len > 0) { const new = sam.apply(c.p.gpa, f.content, res.ops) catch |err| return c.p.reportError(c.id, "Edit", err); - panes.File.pushUndo(c.p, c.pane); - panes.File.setContent(c.p, f, new); + // `s/a/a/` changes nothing: no undo step, no new revision. + if (std.mem.eql(u8, new, f.content)) c.p.gpa.free(new) else { + panes.File.pushUndo(c.p, c.pane); + panes.File.setContent(c.p, f, new); + } } ninep_pane.setDot(c.pane, sam.moveDot(res.dot, res.ops)); if (res.printed.len > 0) _ = ninep_pane.appendErrors(c.p, c.id, res.printed); -- cgit v1.3