summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-25 09:57:56 -0300
committerGabriel Schneider <[email protected]>2026-11-25 09:58:56 -0300
commit6d90badbf94dcee1c8a123153fb331b8c523c9f1 (patch)
tree2223fcf9398a956e3d7aa44d7847ef537544924e /core
parent1902703adec3e8461d623fe6e867bc8adb1e52e0 (diff)
downloadpardes-6d90badbf94dcee1c8a123153fb331b8c523c9f1.tar.gz
pardes-6d90badbf94dcee1c8a123153fb331b8c523c9f1.zip
Pick: a picker's band is capped once, at open, at 40 % of its host pane's rows (UX D6 as E3 amends it, DESIGN.md E5.1), so the layout that borrows the host's body from its column sees the band the pane will have: a Grep from a held pane at 100x30 previews 11 rows (the old +Preview's 8 is E7's pass mark; P1's tree showed 6 at 26 px); TEST FIRST: Pick.zig "a picker's band is capped once at open at 40 % of its host pane's rows; the host borrows from its column for a body of 60 % before the band gives way: a Grep from a held pane at 100x30 previews 8 rows at least" (a held pane, Grep `pub fn` over a file of 40 such lines, Down: on the base the reader made for it, 14 rows at open, kept 14 (2 tag rows, a band of 6, a body of 6, under 60 %) while the held pane kept its 13: `expected 5, found 6`); THE CAUSE: Pick.bandRows took 40 % of the host's COLUMN from `v.rects`, and layout.compute zeroes every rect before it lays the columns out (`v.rects = @splat(.{})`), so the floor it asked while borrowing (layout.floorRows -> Band.takes -> bandRows) was a band of 1 row: nothing was borrowed, and the sync after it (rects laid out) held the band to what the pane had left over a body of 6; P1's reading 5 (the column) is E4's ruling 5 reversed: the host PANE's rows; THE FIX: `Pick.cap`, set in `open` from the host's rect (laid out: landingFor lays a reader made for the picker out), read by bandRows in place of the column (in the dump and the digest with the picker: the layout's term is the state's); the band may still grow with the list (Find's names) up to the cap, never past 11; GOLDEN: fsearch (list, ctrln): the reader borrows one row from the pane above (rows 15-29 where 16-29: 2 tag rows, the band of 4, a body of 9 = 60 %, where it kept 8), so the head is on row 15 and the body shows one more line (9, 11); landed: row 15 goes back to the pane above, blank, as leaving the state gives every pane its rows back; no other golden moved; core-test 1085/1256 (171 skipped), process-test 1 of 147 failed before the golden (fsearch, regenerated with `-- --update fsearch`)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core')
-rw-r--r--core/Pick.zig48
1 files changed, 41 insertions, 7 deletions
diff --git a/core/Pick.zig b/core/Pick.zig
index c5b639cd..fe7454b3 100644
--- a/core/Pick.zig
+++ b/core/Pick.zig
@@ -94,6 +94,10 @@ owner: u32 = 0,
landing: u32 = 0,
/// The landing pane was made for it: Esc takes it away.
made: bool = false,
+/// Its band's rows at most: 40 % of its host pane's rows at open (UX D6),
+/// fixed: the layout that borrows the host's body from its column reads
+/// it, and a pane laid out again changes it no more than typing does.
+cap: u16 = 0,
/// Unrolled in a view's tag now.
unrolled: bool = false,
names: Names = .{},
@@ -192,6 +196,7 @@ pub fn open(p: *Pardes, from: usize, source: Source, word: []const u8, query: []
pk.dir.set(Pardes.paneDir(asker));
pk.rows = p.gpa.dupe(u8, rows) catch |err| return p.reportError(.at(from), "pick", err);
hostIn(p, pk, from) catch |err| return p.reportError(.at(from), "pick", err);
+ if (p.paneBySerial(pk.landing)) |host| pk.cap = p.view().rects[host].h * 2 / 5;
unroll(p, pk, query);
start(p, pk);
filter(p, pk);
@@ -669,16 +674,13 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?TagState.Head {
/// The band's rows (UX D6): as many as the list will show, from what the
/// source has (not what the query keeps: typing never moves the body),
-/// four at least, eleven at most, and 40 % of the host's column at most
-/// (its panes' rows, which a borrow moves between them, never changes).
+/// four at least, eleven at most, and its `cap` at most (the host pane's
+/// 40 % at open: the layout asks this while it lays the column out, when
+/// no pane has its rows yet).
pub fn bandRows(p: *const Pardes) u16 {
const pk = live(p) orelse return 0;
const have = if (!fuzzy(pk)) Band.Cursor.shown else pk.names.cands.items.len;
- const v = p.view();
- const at = @import("layout.zig").findPane(p, TagState.hostOf(p) orelse return 0) orelse return 0;
- var column: usize = 0;
- for (v.cols[at.col].panes[0..v.cols[at.col].n]) |id| column += v.rects[id].h;
- const rows: usize = @max(1, @min(Band.Cursor.shown, @max(4, have), column * 2 / 5));
+ const rows: usize = @max(1, @min(Band.Cursor.shown, @max(4, have), pk.cap));
// Its second step's rows too: the sources, the acts and what they act on.
return @intCast(switch (pk.spine) {
.sources => @max(rows, spine_rows.len),
@@ -1830,6 +1832,38 @@ test "a picker's band is sized from its list at open, 4 rows at least, and typin
try std.testing.expectEqual(rows, p.panes[reader].?.band_rows);
}
+test "a picker's band is capped once at open at 40 % of its host pane's rows; the host borrows from its column for a body of 60 % before the band gives way: a Grep from a held pane at 100x30 previews 8 rows at least" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
+ defer p.deinit();
+ p.settings.jumps = .walk;
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ var text: std.ArrayList(u8) = .empty;
+ defer text.deinit(std.testing.allocator);
+ for (0..40) |i| try text.print(std.testing.allocator, "pub fn f{d}() void {{}}\n", .{i});
+ const a_path = try testFile(p, &tmp, "alpha.zig", text.items);
+ defer p.gpa.free(a_path);
+ _ = try p.setTestFile("held\n");
+ const asker = p.view().active;
+ Trail.keep(p.panes[asker].?);
+ p.gpa.free(p.panes[asker].?.file.?.path);
+ p.panes[asker].?.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ std.Io.Dir.path.dirname(a_path).?, "held.txt" });
+ p.stream.engine = .walk;
+ p.sync();
+ open(p, asker, .grep, "", "", "");
+ const reader = p.paneBySerial(live(p).?.landing).?;
+ const at_open = p.view().rects[reader].h;
+ for ("pub fn") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
+ settle(p);
+ p.update(.{ .key = .{ .cp = Key.down } });
+ p.sync();
+ const pane = p.panes[reader].?;
+ const r = p.view().rects[reader];
+ try std.testing.expectEqual(@min(Band.Cursor.shown, at_open * 2 / 5), pane.band_rows);
+ try std.testing.expect(r.h - pane.tag_rows >= 8);
+ try std.testing.expect(@as(u32, r.h - pane.tag_rows) * 5 >= @as(u32, r.h) * 3);
+}
+
test "a picker's keys: Tab marks and moves, M-a all and none, C-SPC refines and Backspace undoes it, M-h switches source keeping the query" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 140, .rows = 50 });
defer p.deinit();