diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 14:19:43 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 14:29:36 -0300 |
| commit | f7f6b564c0f43aaa31233dcdf1ae7daf24799fe1 (patch) | |
| tree | f63d38c997eb6974e1669cd943851715d6f8ac91 /core | |
| parent | 4062e54f04ec6489a6624141df6620d89fe8de27 (diff) | |
| download | pardes-f7f6b564c0f43aaa31233dcdf1ae7daf24799fe1.tar.gz pardes-f7f6b564c0f43aaa31233dcdf1ae7daf24799fe1.zip | |
tagstate: a rolled level that wraps gives its hints `↓ unroll · ? help` its spare row, its last child going down to leave them room on the last row (UX D3: the same right block for every rolled level): S2's 26 px 05d showed `]` rolled in two rows at 100 columns without them while SPC's (04a) had them on its third; THE CAUSE (core/TagState.zig head): the children were laid out keeping no room for the hints, which right() then drops whole when the last row has fewer than their 19 cells (two spaces and 17): `]`'s second row had 16; THE FIX: on a level that already wraps and has a row to spare (fewer than 3, a terminal's its own tag rows), the last child keeps the hints' cells (and a struck key's) and goes to the next row when it would leave them none; a level of one row keeps its one row and a level that fills its rows keeps its children, the hints dropping where they do not fit (D3: hints drop first; the earlier test "a rolled level breaks between its children only ..." keeps `SPC h` at 60 columns one row with none); `g` at 100 columns fills its three rows (its third 86 cells of 100, the hints want 19), so S2's 05e keeps none: only a child given to `+N ↓` or a shorter hint could make room, a ruling for UX; TEST FIRST: TagState.zig "a rolled level that wraps has its hints on its last row at every width that leaves it a row to spare ..." (SPC, `]`, `g`, 40 to 160 columns, every two-row level ends with them): fails on the base at TagState.zig:1382 (a two-row level without them, as `]` at 100 columns); core-test filtered "a rolled level" 14/14; the sweeps before it (3 rows at most at every width, a terminal's tag rows kept, `SPC h` one row) hold
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/TagState.zig | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/core/TagState.zig b/core/TagState.zig index 761eec48..e8ba816e 100644 --- a/core/TagState.zig +++ b/core/TagState.zig @@ -734,13 +734,20 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?Head { }; level = level[0..n]; } + // Its hints on its last row, by the right block's rule (UX D3): a + // level that wraps gives them its spare row, its last child going to + // it to leave them room; a level of one row or of all its rows keeps + // its rows, and they drop where they do not fit. + const hint = "↓ unroll · ? help"; + const hinted = 2 + panes.File.displayWidth(tab, hint); var rows: usize = 1; for (level, 0..) |c, i| { const label = if (registers) try bindings.registerShown(arena, tab, bindings.registerValue(p, c.key)) else c.label; const cut = c.group or (c.more and !registers); const w = panes.File.displayWidth(tab, bindings.keyName(c.key)) + 1 + panes.File.displayWidth(tab, label) + @intFromBool(cut); var gap: usize = if (i == 0) 1 else 2; - if (b.col() + gap + w + more(level.len - i - 1, rows == most) + (if (rows == most) struck else 0) > b.width and rows < most and b.col() > indent) { + const last: usize = if (i + 1 == level.len and rows > 1) struck + hinted else 0; + if (b.col() + gap + w + more(level.len - i - 1, rows == most) + (if (rows == most) struck else last) > b.width and rows < most and b.col() > indent) { try b.row(indent); rows += 1; gap = 0; @@ -767,9 +774,8 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?Head { if (b.col() + struck > b.width and rows < most) try b.row(indent) else try b.put(" "); try b.styled(bindings.keyName(s.miss), .strike); } - // Its hints on its last row, by the right block's rule (UX D3). const hints = b.text.items.len; - try b.styled("↓ unroll · ? help", .dim); + try b.styled(hint, .dim); try b.right(hints, hints); return b.done(); } @@ -1364,3 +1370,23 @@ test "a click that gives the keyboard to another pane ends a level as Esc does; click(p, rt.x + config.GUTTER + 1, rt.y + pardes.BOX_H); try std.testing.expect(p.view().tag_state.kind == .rest and hostOf(p) == null); } + +test "a rolled level that wraps has its hints on its last row at every width that leaves it a row to spare: `]` and `g` as SPC (UX D3)" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 }); + defer p.deinit(); + _ = try p.setTestFile("one\n"); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + const a = frame.allocator(); + for (" ]g") |root| for (40..161) |cols| { + p.update(.{ .resize = .{ .cols = @intCast(cols), .rows = 40 } }); + p.update(.{ .key = .{ .cp = root } }); + p.advance(p.clock.now_ns); + p.clock.now_ns = p.view().tag_state.due_ns; + try std.testing.expect(hostOf(p) != null); + const tag = try testTag(p, a); + if (std.mem.count(u8, tag, "\n") == 1) try std.testing.expect(std.mem.endsWith(u8, tag, " ↓ unroll · ? help")); + p.update(.{ .key = .{ .cp = pardes.Key.escape } }); + try std.testing.expect(hostOf(p) == null); + }; +} |
