diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 11:58:41 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 12:37:18 -0300 |
| commit | 7e4d1d727487455376c54695bb13683b9d1e5cc9 (patch) | |
| tree | 5a25769e0105d7902d019c0954616e02963e8879 /core/Trail.zig | |
| parent | ae138cd257f862f226f3f9561b98b7c0518bfcf5 (diff) | |
| download | pardes-7e4d1d727487455376c54695bb13683b9d1e5cc9.tar.gz pardes-7e4d1d727487455376c54695bb13683b9d1e5cc9.zip | |
tagline, Trail, layout: a walk step never refuses and never takes a row its column cannot give (the coordinator's ruling on seeds 109 and 162, D8 "the walk never adds a row at rest" with D2 "paths cut from the left"): where the step's tag at rest, its older steps folded into `+N` and its newest whole, still wants more rows than its pane has over min_body_rows, it keeps the newest step alone and cuts its PATH from the left with `…` to fit them, its basename always whole (`‹@p7 › f.txt:1 › …ry/f.txt Keep Save …`); a column with a row to give still grows the tag as before (C7), a row at a time from whichever pane has the most above its own minimum (Trail.lift, layout.giveRow), the cut only for what it cannot give; the full path stays reachable on the notice row at rest (`path:line` of the focused pane, as wide as the window) and in the name a B1 click on the cut path drafts (the whole path, its caret where the click was; Esc to normal mode and Esc again drop the draft and put the cut back); THE CAUSE: the walk's fold (tagline.folded) stopped at the newest step whole, as D8 says, and nothing held the path: a reading pane stepping to a long path in a column with no rows to give (seed 109: 17 rows, `‹@p7 › f.txt:1 › <81-cell path> Keep …` in 48 cells wanting 4 rows where its pane had 5, every pane of column 2 at its minimum; seed 162: a step in place from a short path to a long one) wrapped its tag onto a row the column could not give, and Trail.lift left the pane under its tag and two rows; THE FIX: tagline.folded returns a Fold (`whole`, `cut`, `squeezed`), derived each time from the pane's own rows (its rect less min_body_rows), the cells its walk, name, Keep and tail take, for a pane that walked (a reading file with a step besides its owner and where it is), not drafting a name, unfolded and laid out: no new pane state, no dump or digest change; restPath writes the cut name, and every offset taken from the name follows it (forwardSpan, onName, typedIntoName, draw.zig tagTintRange's basename tint), so layout.wantedTagRows and minRows take the cut tag's rows on their own; Trail.lift then grows the tag while it is squeezed and its column has a row to give; a held pane, a reading pane that has not stepped, a fresh reader (its placement measures it as before) and Jumps new-pane are as they were; TEST FIRST: Trail.zig "a step whose tag would take a row its column cannot give folds to its newest step and cuts its path from the left, `…` and the basename whole, and takes no row; a column with a row to give grows its tag as before" (fails on the base at Trail.zig:926: the column under its minimums after the step), and ninep/tree.zig "random placements, refused or not, leave no pane under its tag and two rows" unpinned from `Jumps new-pane` to the walk default (fails on the base: seed 109 rows 17 step 36 action 5, column 2 under its minimums, pane 2 h 5 min 6); both pass now, P1's Pick test "after Enter the list is a word in the reader's trail…" with them; Trail.zig's tagCell helper finds a word on whichever row the tag wrapped it onto; SEEN at 26 px (X3/png/cut-path-full-column-26px.png: a held pane and its reader each at their 4 rows, the reader's step to a 188-byte path cut to `‹@p1 › Band.zig:10 › …/proj/the-reading-pane-walks-on-…/long.zig Keep Save …` in its two tag rows; column-with-rows-grows-tag-26px.png: the same step in a 30-row window, the tag grown to three rows, the whole path); core-test 1089/1260 (171 skipped), shell-test 1308/1311, pane-test 183/184, behaviour-test 280/280 (no golden moved) and --replay 20 seeds 0 failures, term-test 17/17, kitty-test 45/45, process-test 0 of 147 failed (3 skipped), the 5-client soak at rtt 30/80/207: 0 diverged, 0 unequal, quiet checks 536/0, 404/0, 636/0, unlisted stops 0, the corpus scene 22 of 22, no leak; gui unit-test 1905/1910 (4 skipped): its one failure, Ptys "a reader delivers a real shell's tail before its end of file" (dev/Ptys.zig:327, at load 7-10), passes run alone, and the perf check's known BaselineHarnessMismatch; no 40,000-seed fuzz (neither the dump nor the digest changed)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/Trail.zig')
| -rw-r--r-- | core/Trail.zig | 96 |
1 files changed, 93 insertions, 3 deletions
diff --git a/core/Trail.zig b/core/Trail.zig index c2c1b0c3..0caf1d9b 100644 --- a/core/Trail.zig +++ b/core/Trail.zig @@ -244,12 +244,16 @@ fn show(p: *Pardes, id: usize, path: []const u8, at: Spot) !usize { /// Pane `id`'s tag after a step may take more rows than it had (its walk's /// words, a longer name): it is given them from its column, as a step that /// wraps tags gives them (layout.restoreMinimaFrom), the others keeping -/// their own minimum. +/// their own minimum: a row at a time while its tag is folded to its newest +/// step or its path cut for want of them (tagline.folded). What the column +/// cannot give, the step never takes: the tag stays cut. fn lift(p: *Pardes, id: usize) void { const now = p.view().rects; var floor = layout.minima(p); floor[id] = 0; layout.restoreMinimaFrom(p, &now, &floor); + const pane = p.panes[id] orelse return; + while (pardes.tagline.folded(p, pane).squeezed and layout.giveRow(p, id)) {} } /// `s`, a search's or a recipe's word, the pane's one of its kind (§7.3, @@ -722,13 +726,17 @@ test "the reader of a held pane too short to halve goes to the bottom of the nex try std.testing.expectEqual(col + 1, layout.findPane(f.p, reader_id).?.col); } -/// Where `word` starts in pane `id`'s tag, on the screen. +/// Where `word` starts in pane `id`'s tag, on the screen: on whichever of +/// its rows the tag wrapped it onto. fn tagCell(p: *Pardes, id: usize, word: []const u8) ![2]u16 { const pane = p.panes[id].?; const tag = try tagOf(p, pane); const i = std.mem.indexOf(u8, tag, word) orelse return error.NotInTag; + const shown = try pardes.tagline.shownTag(p, p.scratch.allocator(), pane); + const at = modal.positionAt(shown.text, shown.fromReal(i)); + const col = panes.File.rawDisplayCol(p.settings.tab, modal.lineSlice(shown.text, at.row), at.col); const r = p.view().rects[id]; - return .{ r.x + pardes.TAG_TEXT_INSET + @as(u16, @intCast(panes.File.displayWidth(p.settings.tab, tag[0..i]))), p.tagTop(pane, r) }; + return .{ r.x + pardes.TAG_TEXT_INSET + @as(u16, @intCast(col)), p.tagTop(pane, r) + @as(u16, @intCast(at.row)) }; } /// A click with `button` on `word` in pane `id`'s tag: a press and a @@ -892,6 +900,88 @@ test "the walk never adds a row to a tag at rest: its steps fold further, down t try std.testing.expect(std.mem.indexOf(u8, try tagOf(p, pane), " › +") != null); } +test "a step whose tag would take a row its column cannot give folds to its newest step and cuts its path from the left, `…` and the basename whole, and takes no row; a column with a row to give grows its tag as before" { + var f: Fixture = .{ .p = undefined, .tmp = undefined }; + try f.init(60); + defer f.deinit(); + const p = f.p; + const v = p.view(); + // A path some 115 cells longer than rank.zig's, wider than a tag's row + // here: its tag wraps onto a row more than rank.zig's. + const deep = "a-directory-whose-name-runs-on-past-a-tag-row/" ++ "and-one-more-whose-name-runs-on-as-well/" ++ "and-a-third-for-good-measure/long.zig"; + try f.tmp.dir.createDirPath(std.testing.io, std.Io.Dir.path.dirname(deep).?); + try f.tmp.dir.writeFile(std.testing.io, .{ .sub_path = deep, .data = "a\nb\nc\nd\n" }); + var full_buf: [4096 + 256]u8 = undefined; + const full = try std.fmt.bufPrint(&full_buf, "{s}/{s}", .{ f.dir, deep }); + f.look(f.held, "rank.zig", 12); + var r = v.active; + const c = layout.findPane(p, r).?.col; + // Its column with no row to give: every pane at its minimum. + var need: u16 = 0; + for (v.cols[c].panes[0..v.cols[c].n]) |k| need += layout.minRows(p, k); + p.update(.{ .resize = .{ .cols = 120, .rows = need + p.topBarHeight() + layout.columnBarHeight(p) + layout.noticeRowHeight(p) } }); + try std.testing.expect(layout.shareColumn(p, c)); + for (v.cols[c].panes[0..v.cols[c].n]) |k| try std.testing.expectEqual(layout.minRows(p, k), v.rects[k].h); + const before = v.rects[r]; + f.look(r, deep, 2); + r = v.active; + // In place, its rows as they were, every pane at its minimum. + try std.testing.expectEqual(before, v.rects[r]); + try std.testing.expect(layout.columnAtMinimums(p, c)); + const pane = p.panes[r].?; + try std.testing.expectEqualStrings(full, pane.file.?.path); + // `‹@pN › rank.zig:12 › …` and the path's end, its basename whole. + var tag = try tagOf(p, pane); + var at: [64]u8 = undefined; + const lead = try std.fmt.bufPrint(&at, "‹@p{d} › rank.zig:12 › …", .{p.panes[f.held].?.serial}); + try std.testing.expect(std.mem.startsWith(u8, tag, lead)); + var shown = tag[lead.len..std.mem.indexOf(u8, tag, " Keep ").?]; + try std.testing.expect(shown.len < full.len and std.mem.endsWith(u8, full, shown) and std.mem.endsWith(u8, shown, "/long.zig")); + // A step on to a short path and back: the cut again, its forward step + // after it, dimmed where it is; the basename in the name's ink. + f.look(r, "place.zig", 5); + try clickTag(p, v.active, "long.zig:2", .right); + r = v.active; + try std.testing.expectEqual(before, v.rects[r]); + try std.testing.expect(layout.columnAtMinimums(p, c)); + tag = try tagOf(p, p.panes[r].?); + try std.testing.expect(std.mem.startsWith(u8, tag, lead)); + const ahead = pardes.tagline.forwardSpan(p, p.panes[r].?); + try std.testing.expectEqualStrings(" › place.zig:5", tag[ahead[0]..ahead[1]]); + shown = tag[lead.len..ahead[0]]; + try std.testing.expect(std.mem.endsWith(u8, full, shown) and std.mem.endsWith(u8, shown, "/long.zig")); + var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); + defer arena.deinit(); + const s = try p.render(arena.allocator()); + const base = try tagCell(p, r, "long.zig"); + try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().tag_active_name_fg }, s.at(base[0], base[1]).style.fg); + // A click on the path drafts a name: the whole path, its caret where + // the click was (on the first byte shown after the `…`). + const after = v.rects[r]; + const cell = after.x + pardes.TAG_TEXT_INSET + @as(u16, @intCast(panes.File.displayWidth(p.settings.tab, lead))); + for ([_]pardes.Mouse.Kind{ .press, .release }) |kind| p.update(.{ .mouse = .{ .button = .left, .kind = kind, .col = cell, .row = p.tagTop(p.panes[r].?, after) } }); + p.sync(); + try std.testing.expect(p.panes[r].?.prompt == .name); + try std.testing.expectEqualStrings(full, p.panes[r].?.input.own.?); + try std.testing.expectEqual(@as(i32, @intCast(full.len - shown.len)), p.panes[r].?.input.cur_col); + p.update(.{ .key = .{ .cp = pardes.Key.escape } }); + // Back to rank.zig, a row to give in the column's first pane: the step + // to the long path grows the tag as before, the whole path in it. + try clickTag(p, r, "rank.zig:12", .right); + r = v.active; + p.update(.{ .resize = .{ .cols = 120, .rows = v.screen_h + 6 } }); + for (v.cols[c].panes[0..v.cols[c].n]) |k| p.panes[k].?.vweight = @floatFromInt(layout.minRows(p, k)); + p.panes[v.cols[c].panes[0]].?.vweight += 6; + layout.compute(p); + const short = v.rects[r]; + f.look(r, deep, 2); + r = v.active; + try std.testing.expect(v.rects[r].h > short.h); + try std.testing.expect(layout.columnAtMinimums(p, c)); + tag = try tagOf(p, p.panes[r].?); + try std.testing.expect(std.mem.indexOf(u8, tag, "…") == null and std.mem.indexOf(u8, tag, full) != null); +} + test "two steps whose files have the same name are told apart by the shortest path they do not share; the word n walks is underlined" { var f: Fixture = .{ .p = undefined, .tmp = undefined }; try f.init(60); |
