From acd9e032a147f4aa7ad49110dc2f4fb945e7a9bb Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 27 Sep 2026 20:14:04 -0300 Subject: Keep a pane's filesystem state on the Pane instead of a slot-indexed table addr, limit, the event queue and its readers, pty/data's queue, a waiting run and the /log announcement flag lived in p.fs.panes[slot], reset when the pane went; a reused slot is how the bug class came in. acme keeps the same state on its Window (editors/acme/dat.h:226-266), so now Pane.fs holds it: announced, retired (noteRetire, which still answers a waiting run and drops the listener count first) and freed with the pane itself. Co-Authored-By: Claude Opus 5.5 --- src/fs.zig | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'src/fs.zig') diff --git a/src/fs.zig b/src/fs.zig index 50a446dc..c2e88b10 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -586,7 +586,7 @@ test "virtual body writes can read their input from the same pane" { try write(p, path, pane.file.?.content); try std.testing.expectEqualStrings("same pane contents\n", pane.file.?.content); try std.testing.expectEqual(@as(usize, 2), pane.file.?.history.undo_len); - const events = &p.fs.panes[p.active].events; + const events = &p.panes[p.active].?.fs.events; try std.testing.expect(std.mem.startsWith(u8, events.peek().?, "ED")); events.pop(); try std.testing.expect(std.mem.startsWith(u8, events.peek().?, "EI")); @@ -1240,7 +1240,6 @@ pub const Namespace = struct { snapshots: [tree.screen.snapshot_slots]tree.screen.Snapshot = @splat(.{}), runs: [tree.pty.run_slots]tree.pty.Run = @splat(.{}), out: std.ArrayList(u8) = .empty, - panes: [MAX_PANES]tree.pane.State = @splat(.{}), listeners: u16 = 0, origin: u8 = 'K', /// Reads that found nothing yet, one per open that can wait: the log's @@ -1269,7 +1268,6 @@ pub const Namespace = struct { st.os_paths.deinit(gpa); for (st.snapshots) |snapshot| if (snapshot.bytes) |bytes| gpa.free(bytes); for (&st.runs) |*slot| slot.reset(gpa, 0); - for (&st.panes) |*pf| pf.deinit(gpa); st.log.deinit(gpa); st.out.deinit(gpa); } @@ -1292,16 +1290,6 @@ pub const Namespace = struct { st.out.ensureTotalCapacity(gpa, tree.out_reserve) catch {}; return &st.out; } - - pub fn forget(st: *Namespace, gpa: std.mem.Allocator, id: usize) void { - if (id >= MAX_PANES) return; - st.listeners -= @min(st.listeners, st.panes[id].readers); - st.panes[id].deinit(gpa); - } - - pub fn scripted(st: *const Namespace, id: usize) bool { - return id < MAX_PANES and st.panes[id].readers != 0; - } }; pub fn unmount(p: *Pardes, name: []const u8) !void { -- cgit v1.3