summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 12:41:01 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commitc6b0748b15c1ba222df83f91494a13423a33718c (patch)
treeae80d84904f38b2b8b1359955c9653989339df76 /src
parent7472ae9a2f62f332b1b3f81772c54957adcafab8 (diff)
downloadpardes-c6b0748b15c1ba222df83f91494a13423a33718c.tar.gz
pardes-c6b0748b15c1ba222df83f91494a13423a33718c.zip
After a failed address, one that goes from it (., +, -) says there is none
addr kept the old address under a failed one, and an address written relative to it went from that old one. Such an address now fails with no address: the last one written to addr failed, until one that stands alone is written. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/ninep/pane.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig
index 311a2429..f90a83d8 100644
--- a/src/ninep/pane.zig
+++ b/src/ninep/pane.zig
@@ -584,6 +584,10 @@ fn writeRange(req: Req, pane: *Pane, file: PaneFile) Reply {
const text = bodyOf(pane);
clampAddr(pf, text.len);
const expr = std.mem.trimEnd(u8, req.data, "\n");
+ // One that goes from the address (`.`, `+`, `-`) has none to go from
+ // after a failed one: said, rather than going from the one before it.
+ if (file == .addr and pf.addr_failed and expr.len > 0 and std.mem.indexOfScalar(u8, ".+-", expr[0]) != null)
+ return tree.failText(req.tag, E.INVAL, e_addr_failed);
var a: addressing.Addr = .{ .text = text, .lim = pf.limit, .expr = expr };
var r = if (pairOf(expr)) |pair|
State.Range{ .q0 = @min(pair.q0, clip(text.len)), .q1 = @min(pair.q1, clip(text.len)) }
@@ -1107,6 +1111,18 @@ test "two opens writing one body are two undo steps, however their writes interl
_ = call(p, .{ .tag = 3, .op = .release, .node = body, .handle = b, .opened = true });
}
+test "after a failed address, one that goes from it says there is none" {
+ const p = try withFile(testing.allocator, "one\ntwo\n");
+ defer p.deinit();
+ const addr = Node.of(serialOf(p), .addr);
+ try testing.expectEqual(Status.err, wr(p, addr, "/nomatch/").reply.status);
+ try testing.expectEqualStrings(e_addr_failed, wr(p, addr, ".+1").reply.ename);
+ try testing.expectEqualStrings(e_addr_failed, wr(p, addr, "+1").reply.ename);
+ // An absolute one sets it again, and then `.` works.
+ try testing.expectEqual(Status.ok, wr(p, addr, "2").reply.status);
+ try testing.expectEqual(Status.ok, wr(p, addr, ".").reply.status);
+}
+
test "a name cut across writes is one name, applied once at its newline or its close" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();