summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/Trail.zig45
1 files changed, 45 insertions, 0 deletions
diff --git a/core/Trail.zig b/core/Trail.zig
index b5dff554..c6af03e5 100644
--- a/core/Trail.zig
+++ b/core/Trail.zig
@@ -623,6 +623,51 @@ test "the session of pick-ui §6.7: four jumps across three files, back by a cli
try std.testing.expectEqual(owner, p.panes[fresh].?.trail.steps[0].owner);
}
+test "the walk drawn with a picker's list and the notice row (walk UI G 2e, SPEC §3.7, §6.7): a list handed to a held pane lands in its reader, its word in the reader's trail before the place, the reader's tag in the reading tint with Keep, the held pane's not, n walking the list, the notice row at the foot saying where the caret is" {
+ var f: Fixture = .{ .p = undefined, .tmp = undefined };
+ try f.init(40);
+ defer f.deinit();
+ const p = f.p;
+ p.messages.live_len = 0;
+ const owner = p.panes[f.held].?.serial;
+ var buf: [4096 + 128]u8 = undefined;
+ var want: [4096 + 128]u8 = undefined;
+ // g d from the held pane: its reader, made below it.
+ f.look(f.held, "rank.zig", 12);
+ const r = p.view().active;
+ // A list asked from the held pane (SPC e's places, a server's answer):
+ // its Enter lands in the reader, nothing made.
+ const rows = try std.fmt.bufPrint(&buf, "{s}/place.zig:8:1 of\n{s}/place.zig:40:1 Span\n", .{ f.dir, f.dir });
+ pardes.Pick.open(p, f.held, .list, "Refs", "", rows);
+ try std.testing.expectEqual(p.panes[r].?.serial, p.view().tag_state.host);
+ pardes.Pick.landHere(p);
+ p.sync();
+ // The reader stepped (to another file: a pane of its own, its owner's
+ // word kept), no pane more.
+ var n: usize = 0;
+ for (p.panes) |slot| n += @intFromBool(slot != null);
+ try std.testing.expectEqual(@as(usize, 3), n);
+ const rd = p.view().active;
+ try std.testing.expect(rd != f.held and p.panes[r] == null);
+ try std.testing.expect(std.mem.startsWith(u8, try tagOf(p, p.panes[rd].?), try std.fmt.bufPrint(&want, "‹@p{d} › rank.zig:12 › Refs 1/2 › {s}/place.zig Keep ", .{ owner, f.dir })));
+ var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
+ defer arena.deinit();
+ // The reader's tag in the reading tint, the held one's not; the notice
+ // row, nothing said, where the reader's caret is.
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().tag_reading_bg }, try tagGroundOf(p, &arena, rd));
+ try std.testing.expect(!std.meta.eql(pardes.Color{ .rgb = p.chromeTheme().tag_reading_bg }, try tagGroundOf(p, &arena, f.held)));
+ const s = try p.render(arena.allocator());
+ const foot = s.region(.notice_row, pardes.Region.none).?.rect;
+ var row: std.ArrayList(u8) = .empty;
+ for (0..s.cols) |x| try row.appendSlice(arena.allocator(), s.at(@intCast(x), foot.y).grapheme());
+ try std.testing.expect(std.mem.indexOf(u8, row.items, try std.fmt.bufPrint(&want, "{s}/place.zig:8", .{f.dir})) != null);
+ // n: the list's next place, in place of the current step.
+ typeKeys(p, "n");
+ p.sync();
+ try std.testing.expectEqual(@as(i32, 39), p.panes[rd].?.body.cur_row);
+ try std.testing.expect(std.mem.indexOf(u8, try tagOf(p, p.panes[rd].?), "› Refs 2/2 ›") != null);
+}
+
test "a trail keeps its newest three back steps whole, older ones fold to ·, and a click on a · goes back to its step" {
var f: Fixture = .{ .p = undefined, .tmp = undefined };
try f.init(60);