summaryrefslogtreecommitdiff
path: root/core/File.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/File.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/File.zig')
-rw-r--r--core/File.zig28
1 files changed, 28 insertions, 0 deletions
diff --git a/core/File.zig b/core/File.zig
index 8e464d61..163f40ff 100644
--- a/core/File.zig
+++ b/core/File.zig
@@ -3679,3 +3679,31 @@ test "Syntax off in a patch's pane takes the language's ink and leaves the patch
if (pass == 1) try std.testing.expect(differ);
}
}
+
+test "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" {
+ const gpa = std.testing.allocator;
+ const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 });
+ defer p.deinit();
+ var text: std.ArrayList(u8) = .empty;
+ defer text.deinit(gpa);
+ try text.appendSlice(gpa, "head\n");
+ for (0..40) |i| try text.print(gpa, "\tw{d}", .{i});
+ try text.appendSlice(gpa, "\ntail\n");
+ const pane = try p.setTestFile(text.items);
+ try std.testing.expect(p.executeBuiltinLine(0, "Tab 8"));
+ // The top on line 1's fourth row (at 8 cells a tab), drawn.
+ const f = &pane.file.?;
+ f.scroll = 1;
+ f.scroll_row = 3;
+ var arena: std.heap.ArenaAllocator = .init(gpa);
+ defer arena.deinit();
+ _ = try p.render(arena.allocator());
+ try std.testing.expect(p.executeBuiltinLine(0, "Tab 2"));
+ const drawn = try bodyText(p.settings.tab, arena.allocator(), pane, f);
+ const bytes = try pardes.dump.dumpBytes(p);
+ defer gpa.free(bytes);
+ const loaded = try pardes.dump.load(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }, bytes, null);
+ defer loaded.deinit();
+ const lp = loaded.panes[0].?;
+ try std.testing.expectEqualStrings(try bodyText(loaded.settings.tab, arena.allocator(), lp, &lp.file.?), drawn);
+}