From 3632bbeaa75f912281d0c9d636feb153d04f668e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 3 Nov 2026 17:22:47 -0300 Subject: test: five more of src/pardes.zig's tests through the 9P tree alone (test/behaviour/placement, panes, terminals, modes): an empty active column taking a look from another column's text whole, Collapse folding a pane to its tag (no text drawn, no cursor, its tag still typed into) and restoring it, a pane its whole text fits in never scrolled for a margin, Togglettymode and Ctrl-B sharing the mode's transitions from the body or the tag and a text pane refusing it, Esc back into a file keeping its view where a look's :N centres; Session's where (the first place /screen draws a text); each checked to fail against a break (acmeColumn ignoring the active column, toggleCollapse never unfolding, the scroll margin clamped at the last line alone, toggleTty leaving the tag the keyboard, Last landing centred) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/pardes.zig | 147 --------------------------------------------------------- 1 file changed, 147 deletions(-) (limited to 'src/pardes.zig') diff --git a/src/pardes.zig b/src/pardes.zig index 3d29dfcd..3d6b6e28 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -710,34 +710,6 @@ test "pane-tag Exec prefers Tty and argument builtins before shell fallback" { try std.testing.expectEqualStrings("DefinitelyNotABuiltin\r", sent[0..sent_len]); } -test "Collapse builtin keeps content and restores the pane from its default tag" { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 24, .tty_only = true }); - defer p.deinit(); - const pane = try p.setTestFile("keep this text\n"); - p.sync(); - const height = p.rects[0].h; - const revision = pane.file.?.revision; - for ([_][]const u8{ tagline.pane_tail, tagline.file_pane_tail, tagline.pdf_pane_tail, tagline.terminal_pane_tail }) |tail| - try std.testing.expect(std.mem.endsWith(u8, tail, " Collapse Del")); - - try std.testing.expect(p.executeBuiltinLine(0, "Collapse")); - p.sync(); - try std.testing.expect(pane.collapsed); - try std.testing.expectEqual(@as(u16, BOX_H), p.rects[0].h); - try std.testing.expectEqual(@as(f32, @floatFromInt(height)), pane.vweight); - try std.testing.expectEqual(revision, pane.file.?.revision); - try std.testing.expectEqualStrings("keep this text\n", pane.file.?.content); - try std.testing.expect((try p.render(p.scratch.allocator())).cursor == null); - tagline.enterTag(p, pane); - const tag_cursor = (try p.render(p.scratch.allocator())).cursor orelse return error.MissingTagCursor; - try std.testing.expectEqual(p.rects[0].y, tag_cursor.y); - pane.focus = .body; - try std.testing.expect(p.executeBuiltinLine(0, "Collapse")); - p.sync(); - try std.testing.expect(!pane.collapsed); - try std.testing.expectEqual(height, p.rects[0].h); -} - test "LocationsConfig command reports partial updates and survives restore" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); @@ -851,42 +823,6 @@ test "TreeContext command and custom tag survive a workspace round trip" { try std.testing.expectEqualStrings(" Save Keep Del", tagline.curTail(saved)); } -test "Togglettymode builtin and keyboard chord share mode transitions including edited tags" { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 20, .tty_only = true }); - defer p.deinit(); - const pane = p.panes[0].?; - try std.testing.expect(std.mem.indexOf(u8, tagline.curTail(pane), " Mode ") != null); - try pane.appendTag(" Togglettymode"); - try std.testing.expectEqual(Text.Mode.tty, pane.body.mode); - try std.testing.expect(p.executeBuiltinLine(0, "Togglettymode")); - try std.testing.expectEqual(Text.Mode.normal, pane.body.mode); - p.update(.{ .key = .{ .cp = p.tty_toggle, .ctrl = true } }); - try std.testing.expectEqual(Text.Mode.tty, pane.body.mode); - // The tag has its own mode: the body keeps tty while the tag is typed into. - tagline.enterTag(p, pane); - try std.testing.expect(pane.focus == .tag); - try std.testing.expectEqual(Text.Mode.tty, pane.body.mode); - try std.testing.expect(p.executeBuiltinLine(0, "Togglettymode")); - try std.testing.expectEqual(Text.Mode.normal, pane.body.mode); - try std.testing.expect(pane.focus == .body); - tagline.enterTag(p, pane); - p.update(.{ .key = .{ .cp = p.tty_toggle, .ctrl = true } }); - try std.testing.expectEqual(Text.Mode.tty, pane.body.mode); - try std.testing.expect(pane.focus == .body); - - p.acknowledgePanelPresentation(&.{}); - const tag = try tagline.tagText(p, p.scratch.allocator(), pane); - const x = p.rects[0].x + TAG_TEXT_INSET + @as(u16, @intCast(std.mem.indexOf(u8, tag, "Togglettymode").?)); - const y = p.rects[0].y; - p.update(.{ .mouse = .{ .button = .middle, .kind = .press, .col = x, .row = y } }); - p.update(.{ .mouse = .{ .button = .middle, .kind = .release, .col = x, .row = y } }); - try std.testing.expectEqual(Text.Mode.normal, pane.body.mode); - const file = try p.setTestFile("unchanged\n"); - try std.testing.expect(p.executeBuiltinLine(0, "Togglettymode")); - try std.testing.expectEqual(Text.Mode.normal, file.body.mode); - try std.testing.expectEqualStrings("unchanged\n", file.file.?.content); -} - test "Filter is ordered after Del and toggles only its terminal or +Pager pane" { const testing = std.testing; const del = std.meta.stringToEnum(Builtin, "Del") orelse return error.MissingDelBuiltin; @@ -1259,24 +1195,6 @@ test "first document keeps its originating shell and only opens a column when it } } -test "acme placement: an empty active column takes the new pane whole" { - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 32 }); - defer p.deinit(); - try std.testing.expectEqual(config.Runtime.Placement.acme, p.settings.placement); - p.newColumn(0); // its tag has the keyboard: it is the active column - tagline.exitHeader(p); - p.sync(); - // A Look from the shell's text still lands in the active column, as - // acme's makenewwindow puts it in activecol first (util.c:456). - _ = try p.openTutorView(1); - exec.placeNew(p, 0, 0, 1, .doc); - try std.testing.expectEqualSlices(usize, &.{1}, p.col_panes[1][0..p.col_n[1]]); - try std.testing.expectEqual(@as(usize, 1), p.active); - try std.testing.expectEqual(@as(?usize, 1), p.activeColumn()); - // Never a new column. - try std.testing.expectEqual(@as(usize, 2), p.ncol); -} - test "acme placement: under a pane's text when it has many blank rows, else halving the biggest" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 60 }); defer p.deinit(); @@ -1419,24 +1337,6 @@ test "BootShell keep leaves the untouched boot shell a dragged document joins; r } } -test "a pane its whole text fits in never scrolls to keep a margin" { - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 30 }); - defer p.deinit(); - const pane = try p.setTestFile("one\ntwo\nthree\n"); - // A second pane under it, as acme's placement puts one: right under the - // three lines, which leaves the file exactly three body rows. - const below = p.freeSlot().?; - _ = try p.openTutorView(below); - exec.placeNew(p, 0, 0, below, .doc); - p.active = 0; - p.sync(); - try std.testing.expectEqual(@as(u16, 3), p.rects[0].h - pane.tag_rows); - for ("jj") |c| p.update(.{ .key = .{ .cp = c, .text = &.{c} } }); - p.sync(); - try std.testing.expectEqual(@as(i32, 2), pane.body.cur_row); - try std.testing.expectEqual(@as(i32, 0), pane.scroll()); -} - test "dragging a column's only pane to another leaves that column in place, empty" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 32 }); defer p.deinit(); @@ -8615,53 +8515,6 @@ test "tty output follows only from the bottom" { try std.testing.expect(panes.terminal.scrollbar(sp).offset > live); } -test "Esc back into a file leaves its view where it was" { - if (platform == .web) return; - const gpa = std.testing.allocator; - const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .file = "src/memory.zig" }); - defer p.deinit(); - // Rows are lines: the centring below counts lines, and a wrapped line - // above the cursor would push it out of the view it centres. - p.settings.wrap = false; - p.update(.{ .resize = .{ .cols = 80, .rows = 24 } }); - p.update(.{ .key = .{ .cp = 'n', .alt = true } }); // a shell under the doc - const shell = p.active; - p.update(.{ .key = .{ .cp = Key.escape } }); // back onto the doc - p.sync(); - const doc = p.active; - try std.testing.expect(doc != shell); - const dp = p.panes[doc].?; - try std.testing.expect(dp.file != null); - - // Ride the cursor down until the view has scrolled: it now sits in the - // bottom band, which is exactly where a recenter is visible. - for (0..20) |_| p.update(.{ .key = .{ .cp = 'j' } }); - p.sync(); - const view = dp.file.?.scroll; - const row = dp.body.cur_row; - try std.testing.expect(view > 0); - - p.update(.{ .key = .{ .cp = Key.escape } }); // out to the shell - p.sync(); - try std.testing.expectEqual(shell, p.active); - p.update(.{ .key = .{ .cp = Key.escape } }); // ...and back - p.sync(); - try std.testing.expectEqual(doc, p.active); - - // Nothing moved. The old landing recentred the line under the cursor, so - // coming back repainted the whole screen to show what was already on it. - try std.testing.expectEqual(view, dp.file.?.scroll); - try std.testing.expectEqual(row, dp.body.cur_row); - // ...and the cursor is still on screen, which is all `.nearest` promises. - try std.testing.expect(dp.body.cur_row >= @as(i32, @intCast(view))); - try std.testing.expect(dp.body.cur_row < @as(i32, @intCast(view)) + @as(i32, dp.rows)); - - // The other arm still centres: a look target, a `:NN`, a search hit. - look.focusPaneLine(p, doc, .{ .line = @intCast(row + 1), .col = 1 }, .center); - try std.testing.expect(dp.file.?.scroll != view); - try std.testing.expectEqual(@as(usize, @intCast(row)) -| @as(usize, dp.rows) / 2, dp.file.?.scroll); -} - test "raw tty Esc backs out and Shift-Esc is the program's Esc" { if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24, .file = "mise.toml" }); -- cgit v1.3