summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-23 18:00:35 -0300
committerGabriel Schneider <[email protected]>2026-11-23 18:20:56 -0300
commitb1fb4242c0ab52767df1b8e155edcf2692f37873 (patch)
treec5e10602471c331a0d462a35072d883d65140933 /test
parentdde58f770995dcbc929708048a6e0f390c70f8af (diff)
downloadpardes-b1fb4242c0ab52767df1b8e155edcf2692f37873.tar.gz
pardes-b1fb4242c0ab52767df1b8e155edcf2692f37873.zip
scroll: a view's top is a line and a row within that line's own wrapped rows, and a scroll moves it by rows (P62, round 3, on the layer's new model where the `Changes` layer's lines are lines of the buffer): a wheel's notch, the glide, PageDown/PageUp, zj/zk, Ctrl-d/u, zt/zz/zb and the margin (`scroll_off` now ROWS) go a row at a time through a line wrapped over many rows and through a long description line of the layer, where the base jumped all of a wrapped line's rows at once (the user, 2026-11-23: "the scroll view jumps around near deleted lines on the diff view"; one-row deleted lines were cured by the layer's second step, a wrapped one was not): TESTS FIRST: core/jj.zig "a view scrolls by rows through a line wrapped over 12 rows and a change's description wrapped over several (a line of the layer): ..." (a notch is one row down the whole text and back, the notches the text's rows exactly; PageDown/PageUp a page of rows; zj/zk one; a held j and k keep the cursor's row `scroll_off` rows inside the body) failing on the base at notch 21 (line 20's 12 rows crossed at once), and "a client wheels its session's view a row a notch into a change's description wrapped over several rows ..., agreeing at every notch; a client joined over that view loads its row"; kept from round 1: core/replica.zig's join over a view scrolled into a wrapped line (with a rollback and a dump) and the explorer of a view's rows (30 seeds), dev/gui's glide a row a notch; THE CHANGE, taken from pardes-row-scroll (`xrxmqlnw`) and -2 (`xxzmwnvq`) without their ghost-row "blocks" (a block is now just a line's own rows): `File.State.scroll_row` and `views.PaneView.scroll_row` in the generic walk (digested, dumped, copied; a dump of 34 loads at its lines' first rows), the wire 35; core/File.zig `Top`, `rowIn`/`rowWalked` (a line's rows as fillBody wraps them, `guideOf` shared), `rowOf`, `lineRows`, `top`/`setTop`, `walkRows`/`walkKnown`, `rowsTo`, `rowsOf` (off the map where it holds the line), `mapFresh`, `scrollRows`, `shownRows` (the geometry laid out first), `show` (a cursor's or a result's row inside the band, the line's rows whole when they fit), `textRowLine`, fillBody's skip to the top's row walked once a geometry (`Pane.top_skip`, derived), the geometry's key with `scroll_row` and stored as what the map was made from; the one-row fact `State.widest` (`Widest`, an upper bound kept by the index's own vector passes `countLines`/`fillLines`) so a view whose lines are each one row walks nothing (`oneRow`: line arithmetic, checked against the walk in Debug); `fitEnd` a vector of printable ASCII at a time; the callers in rows: panes.zig `scrollBy(tab, delta)` and `ensureCursorVisible` (a file's through `File.show`), the wheel and the rail and the edge scroll (mouse.zig), Ctrl-d/u (normal.zig `halfPageMove`), zt/zz/zb, Ctrl-f/b and PgUp/PgDn (Text.zig `scrollViewMove`), Look's reveal and centring, Places' `goTo`/`restore`, Query's `showCurrent`/`caretTo`, the frames' `Region.row` and the glide (dev/glide.zig, the window's `topOf`); test/perf.zig's checks by (line, row) and its seek at a line's first row; Debug in the workspace: core-test 963/1129 (166 skipped), shell-test 1172/1175 (3 skipped)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test')
-rw-r--r--test/daemon.py2
-rw-r--r--test/kitty.zig2
-rw-r--r--test/panes.zig28
-rw-r--r--test/perf.zig14
-rw-r--r--test/terminal.zig2
5 files changed, 29 insertions, 19 deletions
diff --git a/test/daemon.py b/test/daemon.py
index 90977ef4..cfdac2ec 100644
--- a/test/daemon.py
+++ b/test/daemon.py
@@ -328,7 +328,7 @@ class Replica:
"""A replica's connection (abi/wire.zig): length-prefixed
messages, a tag byte and a little-endian u32 length. It is a near
client: its first word after the hello says so."""
- WIRE = 34
+ WIRE = 35
def __init__(self, path, timeout=10):
self.path, self.timeout = path, timeout
diff --git a/test/kitty.zig b/test/kitty.zig
index 0bd849c2..37e64949 100644
--- a/test/kitty.zig
+++ b/test/kitty.zig
@@ -1224,7 +1224,7 @@ test "kitty: scrolled back by pardes, an image shows on its row; scrolled forwar
r.feed(0, &nl);
try std.testing.expectEqual(@as(usize, 0), (try r.placesOf(20)).len);
// Back to the top of the history: the marker row is the body's first.
- pane.scrollBy(-1000);
+ pane.scrollBy(pardes.config.tab_width, -1000);
const o = r.origin(0);
const drawn = try r.placesOf(20);
try std.testing.expectEqual(@as(usize, 1), drawn.len);
diff --git a/test/panes.zig b/test/panes.zig
index bd39beba..eea4b36d 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -157,7 +157,7 @@ const BodyHitTests = struct {
p.view().row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 10 };
const pane = try TreeContextTests.setZigFile(p, "const Box = struct {\n pub fn work(\n value: usize,\n ) void {\n" ++ std.mem.asBytes(&@as([60][16]u8, @splat(" // body\n".*))) ++ " }\n};\n");
try std.testing.expect(p.executeBuiltinLine(0, "TreeContext"));
- pane.scrollBy(10);
+ pane.scrollBy(pardes.config.tab_width, 10);
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
p.sync();
@@ -205,7 +205,7 @@ const LineNumberLookTests = struct {
p.view().row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 10 };
const pane = try TreeContextTests.setZigFile(p, "const Box = struct {\n pub fn work(\n value: usize,\n ) void {\n" ++ std.mem.asBytes(&@as([60][16]u8, @splat(" // body\n".*))) ++ " }\n};\n");
try std.testing.expect(p.executeBuiltinLine(0, "TreeContext"));
- pane.scrollBy(30);
+ pane.scrollBy(pardes.config.tab_width, 30);
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
p.sync();
@@ -219,7 +219,7 @@ const LineNumberLookTests = struct {
const rows = [_]u16{ 1, pane.context_rows + 3 };
for (rows) |row| {
// Each Look recentres the view; come back under the headers.
- pane.scrollBy(30 - pane.scroll());
+ pane.scrollBy(pardes.config.tab_width, 30 - pane.scroll());
_ = frame.reset(.retain_capacity);
_ = try p.render(frame.allocator());
const expected = pane.wrapAt(config.tab_width, row).line;
@@ -262,7 +262,7 @@ const TreeContextTests = struct {
const pane = try setZigFile(p, "const Box = struct {\n\n // omitted member comment\n\n pub fn work(\n value: usize,\n ) void {\n" ++ std.mem.asBytes(&@as([30][16]u8, @splat(" // body\n".*))) ++ " }\n};\n");
p.view().row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 10 };
try std.testing.expect(p.executeBuiltinLine(0, "TreeContext"));
- pane.scrollBy(10);
+ pane.scrollBy(pardes.config.tab_width, 10);
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
p.sync();
@@ -278,7 +278,7 @@ const TreeContextTests = struct {
// A one-pixel separator remains inside its existing header row.
try std.testing.expectEqual(row, layer.bodyHit(x, y, 10, 20, 8, 10).?.row);
}
- pane.scrollBy(-5);
+ pane.scrollBy(pardes.config.tab_width, -5);
_ = try p.render(frame.allocator());
try std.testing.expectEqual(@as(u16, 2), layer.context_rows);
try std.testing.expect(layer.hasContextBorderAfter(0));
@@ -317,7 +317,7 @@ const TreeContextTests = struct {
const pane = try setZigFile(p, source);
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
- pane.scrollBy(7);
+ pane.scrollBy(pardes.config.tab_width, 7);
p.sync();
_ = try p.render(frame.allocator());
try std.testing.expectEqual(@as(u16, 0), pane.context_rows);
@@ -348,7 +348,7 @@ const TreeContextTests = struct {
p.update(.{ .key = .{ .cp = Key.escape } });
var previous: u16 = pane.context_rows;
while (pane.scroll() > 0) {
- pane.scrollBy(-1);
+ pane.scrollBy(pardes.config.tab_width, -1);
_ = try p.render(frame.allocator());
try std.testing.expect(pane.context_rows <= previous);
previous = pane.context_rows;
@@ -357,7 +357,7 @@ const TreeContextTests = struct {
try std.testing.expectEqual(@as(u16, 0), pane.context_rows);
try std.testing.expectEqual(@as(i32, 0), pane.wrapRow(config.tab_width, 0, pane.body.cur_col).row);
try std.testing.expect(p.executeBuiltinLine(0, "TreeContext"));
- pane.scrollBy(7);
+ pane.scrollBy(pardes.config.tab_width, 7);
_ = try p.render(frame.allocator());
try std.testing.expectEqual(@as(u16, 0), pane.context_rows);
}
@@ -370,7 +370,7 @@ const TreeContextTests = struct {
p.sync();
p.settings.wrap = false;
try std.testing.expect(p.executeBuiltinLine(0, "TreeContext"));
- pane.scrollBy(8);
+ pane.scrollBy(pardes.config.tab_width, 8);
pane.hscroll = 4;
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
@@ -409,7 +409,9 @@ const TreeContextTests = struct {
p.sync();
p.settings.wrap = true;
try std.testing.expect(p.executeBuiltinLine(0, "TreeContext"));
- pane.scrollBy(2);
+ // The view's top on line 2 (a scroll's rows would stop in line 0's
+ // three: File.Top).
+ panes.File.setTop(pane, .{ .line = 2 });
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
p.sync();
@@ -994,7 +996,7 @@ test "terminal output keeps following new rows after scrollback eviction" {
for (0..3) |phase| {
if (phase > 0) {
pane.body.mode = .normal;
- pane.scrollBy(-30);
+ pane.scrollBy(pardes.config.tab_width, -30);
try std.testing.expect(pane.termTop() < pages.scrollbar().total - pane.rows);
pardes.keys.enterTty(p, 0);
}
@@ -2032,7 +2034,7 @@ const OutputTests = struct {
try std.testing.expectEqual(next, panes.Output.nextResult(restored_file.content, restored_file.location_rows, path, .{ .line = 2, .col = 5 }));
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
- result.scrollBy(-1000);
+ result.scrollBy(pardes.config.tab_width, -1000);
layout.compute(p);
const surface = try p.render(frame.allocator());
const rect = p.view().rects[pane.search_pane.?];
@@ -2690,7 +2692,7 @@ const TerminalTests = struct {
p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } });
}
p.shell_rows.stale = true;
- pane.scrollBy(-20);
+ pane.scrollBy(pardes.config.tab_width, -20);
// ONE buffer line standing in for SIX shell rows: everything below slides
// UP five, so the last rows of the body resolve past the viewport's bottom
diff --git a/test/perf.zig b/test/perf.zig
index 8622e31b..f36d64ac 100644
--- a/test/perf.zig
+++ b/test/perf.zig
@@ -631,7 +631,7 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u
for (0..warmup + reps) |n| {
if (op != .deep_selection) seek(pane, fx, n);
_ = try frame(core); // settle the view at the new spot, untimed
- const before = .{ .row = pane.body.cur_row, .col = pane.body.cur_col, .scroll = pane.scroll(), .len = pane.file.?.content.len };
+ const before = .{ .row = pane.body.cur_row, .col = pane.body.cur_col, .scroll = pane.scroll(), .scroll_row = pane.file.?.scroll_row, .len = pane.file.?.content.len };
const rect = core.view().rects[id];
const wheel_col = rect.x + pardes.config.GUTTER;
const wheel_row = rect.y + pardes.BOX_H;
@@ -658,9 +658,11 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u
return error.RenderChangedDocument,
.key_down => if (pane.body.cur_row != before.row + 1) return error.DownDidNotMove,
.key_right => if (pane.body.cur_row != before.row or pane.body.cur_col != before.col + 1) return error.RightDidNotMove,
- .page_down => if (pane.scroll() <= before.scroll and before.scroll < @as(i32, @intCast(fx.lines)) - pane.rows)
+ // A view moves by rows (File.Top): inside a wrapped line's
+ // block its line stays and its row goes on.
+ .page_down => if (!past(pane, before.scroll, before.scroll_row) and before.scroll < @as(i32, @intCast(fx.lines)) - pane.rows)
return error.PageDidNotScroll,
- .wheel => if (pane.scroll() <= before.scroll and before.scroll < @as(i32, @intCast(fx.lines)) - pane.rows)
+ .wheel => if (!past(pane, before.scroll, before.scroll_row) and before.scroll < @as(i32, @intCast(fx.lines)) - pane.rows)
return error.WheelDidNotScroll,
.edit_char, .edit_twin => {
if (pane.file.?.content.len != before.len + 1 or pane.body.cur_row != before.row or pane.body.cur_col != before.col + 1)
@@ -1884,6 +1886,7 @@ fn seek(pane: *pardes.Pane, fx: Fixture, n: usize) void {
const span = @max(1, fx.lines * 8 / 10);
const row = fx.lines / 10 + (n *% 7919) % span;
f.scroll = @min(row, fx.lines -| 1);
+ f.scroll_row = 0;
f.syntax_dirty = true;
pane.body.cur_row = @intCast(f.scroll);
pane.body.cur_col = if (fx.cols > 200) @intCast(fx.cols * 3 / 4) else 0;
@@ -2401,3 +2404,8 @@ fn readFileAlloc(path: []const u8) ![]u8 {
}
return buf;
}
+
+/// Whether `pane`'s view's top is past (`line`, `row`).
+fn past(pane: *pardes.Pane, line: i32, row: u32) bool {
+ return pane.scroll() > line or (pane.scroll() == line and pane.file.?.scroll_row > row);
+}
diff --git a/test/terminal.zig b/test/terminal.zig
index 03bcd294..2873c278 100644
--- a/test/terminal.zig
+++ b/test/terminal.zig
@@ -107,7 +107,7 @@ test "document construction allocates only the pane and has inert terminal defau
try std.testing.expectEqual(Term.Grid{}, grid(pane.terminal));
try std.testing.expectEqual(Term.Modes{}, modes(pane.terminal));
try std.testing.expectEqual(Term.Prompt{}, prompt(pane.terminal));
- pane.scrollBy(100);
+ pane.scrollBy(pardes.config.tab_width, 100);
pane.followOutput();
pane.resizeGrid(undefined, 80, 24); // no terminal: the core is never read
try std.testing.expectEqual(Term.Grid{}, grid(pane.terminal));