From d815a5cc854b3cd14a89f401565db212c3dc9d88 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 11:26:35 -0300 Subject: text journal, the ring and undo over it: a file's undo is the journal of its edits (Text.Journal: entries of an offset, the bytes taken out and the count put in, grouped in steps between marks, each step with the place it began at and the place it was undone from), bounded at 256 steps or 64 MiB, the newest kept; pushUndo marks a step (none when the last changed nothing, as a snapshot equal to the text was none) and every edit goes into the last step, joined to its last entry when they touch (typing on, backspace over it, a write going on where the last ended); undo and redo turn a step's entries round, one in place, several in a copy whose gap moves from one to the next (File.Gap), one edit and one revision as the snapshot's was; the snapshots go (File.Snapshot, the undo and redo arrays and their copies of the whole text at every step); the replica's copy pins an entry's bytes (Entry.removed, a blob) as it pinned a snapshot's; tests: 'undo keeps its steps within a byte bound, the newest always' reads the journal, 'file history owns bounded snapshot storage without per-edit bookkeeping allocations' becomes 'file history keeps its last undo_max steps, and an undo or redo with no memory changes nothing', the far join's blob test makes its two blobs beside the text with a delete and a yank (its history held whole texts before), and the counts of steps read history.journal.done Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/edit_cmd.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/edit_cmd.zig') diff --git a/src/edit_cmd.zig b/src/edit_cmd.zig index 517f2e8d..99cac6ce 100644 --- a/src/edit_cmd.zig +++ b/src/edit_cmd.zig @@ -565,7 +565,7 @@ test "Edit's < | and > with a real shell: a command per address, > printed to +E try testing.expectEqual(@as(usize, 3), p.pipe.edit_run.?.request.inputs.len); try runReal(p); try testing.expectEqualStrings("ONE TWO\nTHREE\n", p.panes[0].?.file.?.content); - try testing.expectEqual(@as(usize, 1), p.panes[0].?.file.?.history.undo_len); + try testing.expectEqual(@as(usize, 1), p.panes[0].?.file.?.history.journal.done); try testing.expectEqual(tree.Status.ok, th.wr(p, ctl, "Edit 2 < printf new\n").reply.status); try runReal(p); try testing.expectEqualStrings("ONE TWO\nnew", p.panes[0].?.file.?.content); @@ -585,7 +585,7 @@ test "a failing command changes nothing and says why, its stderr in +Errors" { p.fs.edit_hold = .{ .asker = @ptrCast(p), .slot = 0, .seq = 1, .tag = 2, .node = ctl, .handle = 0, .written = 1 }; try runReal(p); try testing.expectEqualStrings("keep\n", p.panes[0].?.file.?.content); - try testing.expectEqual(@as(usize, 0), p.panes[0].?.file.?.history.undo_len); + try testing.expectEqual(@as(usize, 0), p.panes[0].?.file.?.history.journal.done); // The held write's answer is the failure, in its words. try testing.expectEqualStrings("Edit: | echo boom >&2; exit 3: exit status 3", filesystem.EditHold.answer(&p.fs).ename); const report = errorsText(p).?; -- cgit v1.3