diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-08 20:55:29 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-08 21:48:19 -0300 |
| commit | b3504bcd020e43d160538d44650bf86627abc21d (patch) | |
| tree | d45a0d55454c2f971c914949031dc8a41297859c /src/Core.zig | |
| parent | 3dbd3bbcc7ba00ab4def14dadaf5335e7c566f1e (diff) | |
| download | pardes-b3504bcd020e43d160538d44650bf86627abc21d.tar.gz pardes-b3504bcd020e43d160538d44650bf86627abc21d.zip | |
fix: bytes for a terminal's program past the 4 MiB that may wait behind the effect ring were dropped with no word: parkPendingWrite says so in the pane's message, write: N bytes for the program dropped, past the 4 MiB that may wait for it; a core test writes past the ring and the cap
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/Core.zig')
| -rw-r--r-- | src/Core.zig | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/Core.zig b/src/Core.zig index 65779217..d09c1188 100644 --- a/src/Core.zig +++ b/src/Core.zig @@ -889,7 +889,10 @@ pub fn writeRoom(p: *const Pardes, id: usize) usize { } pub fn parkPendingWrite(p: *Pardes, id: usize, bytes: []const u8) void { - if (p.pending_write_bytes + bytes.len > limits.pending_write_cap) return; + if (p.pending_write_bytes + bytes.len > limits.pending_write_cap) { + var said: [128]u8 = undefined; + return p.setMessage(id, std.fmt.bufPrint(&said, "write: {d} bytes for the program dropped, past the {d} MiB that may wait for it", .{ bytes.len, limits.pending_write_cap >> 20 }) catch unreachable); // two numbers fit 128 + } if (p.pending_write[id]) |*pw| { // Compact what the drain already sent before growing: a burst that // arrives in pieces must not keep re-copying bytes nobody wants. @@ -3812,6 +3815,21 @@ test "a paste larger than the effect ring reaches the program whole and in order try std.testing.expectEqual(@as(usize, 0), p.pending_write_bytes); } +test "bytes for a terminal past what may wait for it are dropped and said, never silently" { + const gpa = std.testing.allocator; + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + while (p.nextEffect()) |_| {} + // Past the ring's room and the cap of what may wait behind it. + const big = try gpa.alloc(u8, p.writeRoom(0) + (1 << 20)); + defer gpa.free(big); + @memset(big, 'z'); + p.emitWrite(0, big); + try std.testing.expectEqual(@as(usize, 0), p.pending_write_bytes); + const pane = p.panes[0].?; + try std.testing.expect(std.mem.indexOf(u8, pane.msg[0..pane.msg_len], "dropped") != null); +} + test "a bracketed paste larger than the ring still closes its bracket" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); |
