summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-25 01:34:52 -0300
committerGabriel Schneider <[email protected]>2026-11-25 01:45:39 -0300
commit4f043652afd528fc453f191f18a2863ad3fd4738 (patch)
treeee682b78b757103ce5113f7e3582420f21caa319 /core
parent980e90eb35b7e122b609520e94afdb47ff851758 (diff)
parentc26745ef409483d0b101131725a135bb5b3c5e7b (diff)
downloadpardes-4f043652afd528fc453f191f18a2863ad3fd4738.tar.gz
pardes-4f043652afd528fc453f191f18a2863ad3fd4738.zip
walk UI M3: fixer H's second fix merged (xkpmuwtz, on vxkunwvk: a byte dump's views not live keep the ranges beside their primaries, the load no longer frees each share's `sels` that views.undumped handed to a parked view: the soak's double free), no conflict (it touches dump.zig and fuzz.zig only; fuzz.zig keeps this line's session with a kept picker, a recipe and a search word); core-test on it 1055/1225 (170 skipped, 0 failed), shell-test 1272/1275, pane-test 183/184; the gates of the merged tree are the next change's
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core')
-rw-r--r--core/dump.zig29
1 files changed, 28 insertions, 1 deletions
diff --git a/core/dump.zig b/core/dump.zig
index 8e44d82d..2dde9c8c 100644
--- a/core/dump.zig
+++ b/core/dump.zig
@@ -455,7 +455,11 @@ fn loadKnowing(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, notes:
else => return err,
};
views.undumped(p, others);
- // What it made, as the mounts' (above).
+ // What it made, as the mounts' (above), but each share's ranges
+ // beside its primary: `undumped` gave them to the core, or freed them.
+ for (others) |o| for (o.panes) |sh| for (l.shared.items[at..]) |*m| {
+ if (sh.pv.body.sels.len > 0 and @intFromPtr(m.bytes.ptr) == @intFromPtr(sh.pv.body.sels.ptr)) m.bytes = &.{};
+ };
for (l.shared.items[at..]) |m| if (m.bytes.len > 0) m.gpa.rawFree(m.bytes, m.alignment, @returnAddress());
l.shared.shrinkRetainingCapacity(at);
afterLoad(p);
@@ -1441,3 +1445,26 @@ test "a load refused after the core frees what a script's open held once: the ro
// refuses the load there.
try std.testing.expectError(error.MountConflict, load(gpa, .{ .mounts = &.{.{ .name = "peer", .dial = "/tmp/other.sock" }} }, bytes, null));
}
+
+test "a byte dump's views not live keep the ranges beside their primaries: loaded, the core holds them, each freed once" {
+ const gpa = std.testing.allocator;
+ const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 });
+ defer p.deinit();
+ const pane = try p.setTestFile("one\ntwo\nthree\nfour\n");
+ // A second cursor below, and a key typed in insert mode at both.
+ for ("Cix") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
+ p.update(.{ .key = .{ .cp = pardes.Key.escape } });
+ const nsel = pane.body.nsel;
+ try std.testing.expect(nsel > 0);
+ // Another view live: the first's share, its ranges, parked, as a
+ // client's is in the session a join's dump is made of.
+ const k = p.openView().?;
+ p.toView(k);
+ const bytes = try byteDump(p);
+ defer gpa.free(bytes);
+ const q = try load(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }, bytes, null);
+ defer q.deinit();
+ try std.testing.expectEqual(walk.digest(Pardes, p), walk.digest(Pardes, q));
+ q.toView(.at(0));
+ try std.testing.expectEqual(nsel, q.panes[0].?.body.nsel);
+}