summaryrefslogtreecommitdiff
path: root/core/normal.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 14:06:54 -0300
committerGabriel Schneider <[email protected]>2026-11-24 14:57:45 -0300
commit8d0b21544824051873950ddcae1d4aab027a01fc (patch)
tree4fd7ca54c65fab8c73df178b0e16fe339a414017 /core/normal.zig
parente332c4c300bd39ba9b2da797391e37ddebda5319 (diff)
downloadpardes-8d0b21544824051873950ddcae1d4aab027a01fc.tar.gz
pardes-8d0b21544824051873950ddcae1d4aab027a01fc.zip
tests: a view's top read off a geometry it is not the view of (row scroll round 4, fault 1, TESTS FIRST, each failing on the base ynxykzrt): the release soak's panic (run 18 of 24, a client's drawOne: `index out of bounds: index 41, len 38` at core/File.zig fillBody `text[from..end]`) is a view drawn after ANOTHER VIEW's step moved the top: the step's `show` hands its next geometry the top's byte (`Pane.top_skip`, keyed for the geometry after the move) while the map stays the one made before it; a view that was where the first was (a client's view opened as a copy of the live one, the same size) has that map's key, so `geometry` returns early and the text pass takes `top_skip.at`, a byte of the OTHER view's top line, with no look at its key: views.zig "a view drawn after another view's step moved the top into a long wrapped line, the two alike before it: ..." panics on the base `index out of bounds: index 1584, len 5` (a probe run first, throwaway, every top_skip read checked against the walk: made by `show`, line 10 row 22, read for line 0); a STEP takes the same stale row (`topNow`): views.zig "a view's step after another view's step moved the top, the two alike before it: it scrolls from its own top's row, as a core loaded from the session (none of its geometry) does" (PageDown in the second view: expected 12, found 14 on the base: a session that drew and a client that did not step apart); and the tab width is not in the geometry's key (a Tab zeroes `geometry_key` but not `top_skip`, whose key matches again: a row start of the old width trusted; in bounds, a wrong row; 180 such reads in one Debug soak with the probe): File.zig "a view scrolled by rows into a line of tabs, the tab width changed after a frame: its body drawn from the row the new width makes, as a core loaded from it draws it" fails on the base (rows from the 8-cell width's byte 27, the 2-cell width's is 74); and a second derived reader of the same kind, found by the table of every reader of a pane's geometry (normal.zig `gotoWindow` read `context_rows` before `shownRows` made the geometry): normal.zig "gt after a step that moved the view off the place its geometry was made for: ..." (two notches up off the held headers, then gt: expected 3, found 5 on the base: the session read the held rows of the place before the notch)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/normal.zig')
-rw-r--r--core/normal.zig32
1 files changed, 32 insertions, 0 deletions
diff --git a/core/normal.zig b/core/normal.zig
index fe0c729a..5a9794ee 100644
--- a/core/normal.zig
+++ b/core/normal.zig
@@ -1527,6 +1527,38 @@ test "gt and gb go to the row scroll_off rows in from the body's top and from it
}
}
+test "gt after a step that moved the view off the place its geometry was made for: the row scroll_off in from the body's top under the context rows the view has now, as a core loaded from the session goes" {
+ const gpa = std.testing.allocator;
+ const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 60, .rows = 16 });
+ defer p.deinit();
+ const pane = try p.setTestFile("pub const Box = struct {\n pub fn run() void {\n" ++ (std.mem.asBytes(&@as([30][21]u8, @splat(" // body line\n".*)))) ++ " }\n};\n");
+ p.gpa.free(pane.file.?.path);
+ pane.file.?.path = try p.gpa.dupe(u8, "/test.zig");
+ if (!File.supportsContext(pane)) return error.SkipZigTest;
+ pane.file.?.tree_context = true;
+ // The view inside the function, its two headers held over the body,
+ // drawn.
+ File.setTop(pane, .{ .line = 3 });
+ p.sync();
+ var arena: std.heap.ArenaAllocator = .init(gpa);
+ defer arena.deinit();
+ _ = try p.render(arena.allocator());
+ try std.testing.expectEqual(@as(u16, 2), pane.context_rows);
+ // Two notches up: the top on the function's header, one header held
+ // (the geometry the second notch read was the one before it).
+ const rect = p.view().rects[0];
+ for (0..2) |_| p.update(.{ .mouse = .{ .button = .wheel_up, .kind = .press, .col = rect.x + 10, .row = rect.y + 5 } });
+ try std.testing.expectEqual(@as(usize, 1), pane.file.?.scroll);
+ const bytes = try pardes.dump.dumpBytes(p);
+ defer gpa.free(bytes);
+ const loaded = try pardes.dump.load(gpa, .{ .tty_only = true, .cols = 60, .rows = 16 }, bytes, null);
+ defer loaded.deinit();
+ for ([_]*Pardes{ p, loaded }) |core| for ("gt") |k| core.update(.{ .key = .{ .cp = k, .text = &[_]u8{k} } });
+ try std.testing.expectEqual(loaded.panes[0].?.body.cur_row, pane.body.cur_row);
+ try std.testing.expectEqual(@as(u16, 1), pane.context_rows);
+ try std.testing.expectEqual(pane.wrapAt(p.settings.tab, 1 + config.scroll_off).line, pane.body.cur_row);
+}
+
test "gw labels the words the body shows and no others: none on a wrapped line's rows above the view's top" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 60, .rows = 24 });
defer p.deinit();