diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-30 19:30:33 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:17 -0300 |
| commit | b2886edda1a1630f38732975c04bdf4d6f6ded29 (patch) | |
| tree | bf9d63ebb5a1f08fe6b11f5b96a8388945e71b66 /src/ninep/addr.zig | |
| parent | 42b68e5ea63c32ff9359f2268ef0d8c08eaafff2 (diff) | |
| download | pardes-b2886edda1a1630f38732975c04bdf4d6f6ded29.tar.gz pardes-b2886edda1a1630f38732975c04bdf4d6f6ded29.zip | |
A refused write to dot after a shell's truncation changes nothing: the truncation waits for the write, as limit's does
echo /nomatch/ > dot truncated dot to an empty range at the top before
the write was refused, so a failed address still moved the selection
and scrolled. The truncation is now held until the write that follows
it: that write sets dot, or, refused, leaves it as it was. A truncation
with no write after it (: > dot) empties it when its open goes.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/addr.zig')
| -rw-r--r-- | src/ninep/addr.zig | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ninep/addr.zig b/src/ninep/addr.zig index df2cfaf0..b78c46e7 100644 --- a/src/ninep/addr.zig +++ b/src/ninep/addr.zig @@ -498,6 +498,28 @@ test "regular expressions search lines as sam's do, and a search wraps" { try testing.expectEqual(@as(u32, 5), q.panes[0].?.fs.addr.q0); } +test "a refused write to dot after a truncation changes nothing; a truncation with no write empties it at close" { + const p = try th.withFile(testing.allocator, "one\ntwo\nthree\n"); + defer p.deinit(); + const serial = th.serialOf(p); + const dot = Node.of(serial, .dot); + try testing.expectEqual(Status.ok, th.wr(p, dot, "2").reply.status); + const was = th.rd(p, dot, 0, 64).bytes; + var kept: [64]u8 = undefined; + @memcpy(kept[0..was.len], was); + // A shell's `echo /nomatch/ > dot`: truncate, then the refused write. + const h = th.call(p, .{ .tag = 1, .op = .open, .node = dot, .omode = 1 }).reply.handle; + _ = th.call(p, .{ .tag = 2, .op = .setattr, .node = dot, .truncate = true }); + try testing.expectEqual(Status.err, th.call(p, .{ .tag = 3, .op = .write, .node = dot, .handle = h, .data = "/nomatch/" }).reply.status); + _ = th.call(p, .{ .tag = 4, .op = .release, .node = dot, .handle = h, .opened = true }); + try testing.expectEqualStrings(kept[0..was.len], th.rd(p, dot, 0, 64).bytes); + // `: > dot`: the truncation alone empties it once its open goes. + const h2 = th.call(p, .{ .tag = 5, .op = .open, .node = dot, .omode = 1 }).reply.handle; + _ = th.call(p, .{ .tag = 6, .op = .setattr, .node = dot, .truncate = true }); + _ = th.call(p, .{ .tag = 7, .op = .release, .node = dot, .handle = h2, .opened = true }); + try testing.expectEqualStrings(" 0 0 ", th.rd(p, dot, 0, 64).bytes); +} + test "a failed address leaves none, so data refuses rather than act at the last one" { const p = try th.withFile(testing.allocator, "one\ntwo\n"); defer p.deinit(); |
