diff options
| -rw-r--r-- | core/Jump.zig | 7 | ||||
| -rw-r--r-- | core/walk.zig | 9 |
2 files changed, 13 insertions, 3 deletions
diff --git a/core/Jump.zig b/core/Jump.zig index 66d0ba51..d85ff75a 100644 --- a/core/Jump.zig +++ b/core/Jump.zig @@ -203,8 +203,9 @@ pub fn trackJump(p: *Pardes) void { }; } // Two in a row the same (a closed one reopened beside its own, - // or the entry between them gone): one entry, one step. - if (w > 0 and std.meta.eql(v.jumps.list[w - 1], kept)) { + // or the entry between them gone): one entry, one step; the same + // as the digest sees them (a text's `place` is bytes undefined). + if (w > 0 and pardes.walk.eql(Loc, &v.jumps.list[w - 1], &kept)) { if (i == v.jumps.cur) cur = w - 1; continue; } @@ -361,7 +362,7 @@ test "the jump list never holds two entries in a row the same, when the one betw p.view().jumps.cur = 3; pane.body.cur_row = 80; // where you are now: far from both trackJump(p); - for (1..p.view().jumps.n) |i| try std.testing.expect(!std.meta.eql(p.view().jumps.list[i - 1], p.view().jumps.list[i])); + for (1..p.view().jumps.n) |i| try std.testing.expect(!pardes.walk.eql(Loc, &p.view().jumps.list[i - 1], &p.view().jumps.list[i])); try std.testing.expectEqual(@as(usize, 3), p.view().jumps.n); try std.testing.expectEqual(@as(u32, 1), p.view().jumps.list[0].line); try std.testing.expectEqual(@as(u32, 150), p.view().jumps.list[1].line); diff --git a/core/walk.zig b/core/walk.zig index d870052d..898a7cf7 100644 --- a/core/walk.zig +++ b/core/walk.zig @@ -89,6 +89,15 @@ pub fn digest(comptime T: type, v: *const T) u64 { return h.final(); } +/// Equal as the digest sees them: what the walk leaves out (a Buf's bytes +/// past its length, a cache) is not compared. std.meta.eql compares every +/// byte of an array, and those bytes are undefined: 0xAA on every Debug +/// process, each release process's own garbage; a decision of the core +/// taken on them agrees between a session and its clients in Debug alone. +pub fn eql(comptime T: type, a: *const T, b: *const T) bool { + return digest(T, a) == digest(T, b); +} + /// A digest of each field `hash` would walk, in order (what a divergence /// is narrowed down by); `names` are theirs. pub fn fieldDigests(comptime T: type, v: *const T, out: []u64) []u64 { |
