diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-30 19:38:59 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:17 -0300 |
| commit | 181170ff00a2019465b6401047407d9914b3b631 (patch) | |
| tree | 6b49f04a1efe29491fa9d4cf23c3aecf5df84197 /src/builtins.zig | |
| parent | b2886edda1a1630f38732975c04bdf4d6f6ded29 (diff) | |
| download | pardes-181170ff00a2019465b6401047407d9914b3b631.tar.gz pardes-181170ff00a2019465b6401047407d9914b3b631.zip | |
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 <[email protected]>
Diffstat (limited to 'src/builtins.zig')
| -rw-r--r-- | src/builtins.zig | 7 |
1 files changed, 5 insertions, 2 deletions
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); |
