From e2452380ed42d3b418930e375780745612d599c5 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 04:56:17 -0300 Subject: An a, c or i text with no . line fails the Edit, as an open { does sam takes the end of input as a text block's end, so a block cut short (a write that lost its tail, an open closed early) inserted half of itself. An Edit whose a, c or i text never meets its . line now fails with "a, c or i text not ended by a . line" and changes nothing, as an unclosed { does; at a close, logged as an err. Co-Authored-By: Claude Opus 5.5 --- src/sam_edit.zig | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/sam_edit.zig') diff --git a/src/sam_edit.zig b/src/sam_edit.zig index 604e2b31..cd2998ef 100644 --- a/src/sam_edit.zig +++ b/src/sam_edit.zig @@ -75,6 +75,11 @@ pub fn run(arena: std.mem.Allocator, text: []const u8, dot: Range, name: []const if (last) |l| l.next = c else first = c; last = c; } + // An a, c or i text that never met its `.` line is refused, as an + // unclosed `{` is: sam takes the end of input for one, but a block that + // reaches Edit unfinished was cut short (a write, an open closed), and + // half of it inserted is worse than none. + if (ps.open_text) return fail(why, "a, c or i text not ended by a . line", .{}); const cmds = first orelse return .{ .ops = &.{}, .dot = dot, .printed = "" }; // acme's u runs at once (ecmd.c:532), outside the edit log; here it is // an Edit of its own. -- cgit v1.3