From f5a6a090da8af3ef6700385cbb301600e23f43ef Mon Sep 17 00:00:00 2001 From: foxnne Date: Fri, 16 Oct 2026 16:38:26 -0500 Subject: [PATCH] layout: test the picker's empty header From #470's review. The empty place's header ("Nothing here yet.") now carries a `picker.empty` anchor, and the picker integration test checks it leads the Sidebar's picker once the Sidebar holds nothing, and is absent from the Panel's. Also corrects a comment that said the sections are sorted. Co-Authored-By: Claude Opus 5.5 --- app/layout/Picker.zig | 5 ++++- tests/integration.zig | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/layout/Picker.zig b/app/layout/Picker.zig index 932d2050d..52c562d15 100644 --- a/app/layout/Picker.zig +++ b/app/layout/Picker.zig @@ -282,7 +282,7 @@ pub fn draw(self: *Picker, f: *Layout) void { const ranked_all = offered(f, ®ion, &query); // Each card under the place holding it, or else the place its keywords make it for; this one // first, so what belongs in the explorer and what in the panel reads off the headers. A - // query ranks within each. Sorted once, not per section. + // query ranks within each. Each card's section is worked out once, not once per section. const sections = f.arena.alloc(usize, ranked_all.len) catch return; for (ranked_all, sections) |ranked, *section| { const s = &f.host.surfaces.items[ranked.item]; @@ -461,6 +461,9 @@ test "a view a place holds is listed under that place, whatever its keywords" { /// The place being edited, when no card falls under it: its header still leads, so the popup /// says which place it fills — a split's new leaf accepts no view's keywords until one is put in. fn emptyHome(region: *const Layout.Region, query: *const core.fuzzy.Query) void { + var box = dvui.box(@src(), .{ .dir = .vertical }, .{ .expand = .horizontal }); + defer box.deinit(); + core.anchor.mark(box.data(), "picker.empty", .{}); sectionHeader(region.name, 0); dvui.labelNoFmt(@src(), if (query.isEmpty()) "Nothing here yet." else "No matching views here.", .{}, .{ .padding = .{ .x = 4, .h = 4 }, diff --git a/tests/integration.zig b/tests/integration.zig index d6ea92919..6892edcd6 100644 --- a/tests/integration.zig +++ b/tests/integration.zig @@ -2520,10 +2520,13 @@ test "the picker lists each view under the place it is made for, the open place for (0..4) |_| _ = try dvui.testing.step(PickerFrame.frame); try std.testing.expectEqual(try y("test.output"), try y("test.files")); try std.testing.expect(try y("test.output") < try y("test.misc")); + // The sidebar holds nothing now, and still leads, empty, under its own name. + try std.testing.expect((try dvui.testing.tagGet("picker.empty")).rect.y < try y("test.files")); editor.app.layout.openPicker(editor.app.gpa, "Panel", null); for (0..4) |_| _ = try dvui.testing.step(PickerFrame.frame); try std.testing.expectEqual(try y("test.output"), try y("test.files")); try std.testing.expect(try y("test.output") < try y("test.misc")); + try std.testing.expect(dvui.tagGet("picker.empty") == null); } test "a hide_when_empty panel stays while its view is dragged onto main" {