summaryrefslogtreecommitdiff
path: root/core/Trail.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-25 12:38:27 -0300
committerGabriel Schneider <[email protected]>2026-11-25 12:50:44 -0300
commite6c384833912598d65c509f0d3a7b713fab0a8eb (patch)
tree8392991253b366e4152df327528ba1c4f8af005f /core/Trail.zig
parent46f004ba04ad6d6299c8967d6890b8f7110db88a (diff)
parent7e4d1d727487455376c54695bb13683b9d1e5cc9 (diff)
downloadpardes-e6c384833912598d65c509f0d3a7b713fab0a8eb.tar.gz
pardes-e6c384833912598d65c509f0d3a7b713fab0a8eb.zip
walk UI M9: X3's seed 109/162 fix (wkylslmo 7e4d1d727487, one change on X2's suvlqwul: a walk step never refuses and never takes a row its column cannot give: a walked reading pane's tag at rest folds to its newest step, then cuts its path from the left, `…` and the basename whole, worked out each time from the pane's own rect by tagline.folded (Fold{whole, cut, squeezed}), restPath writing the cut name; Trail.lift takes a row at a time from the column (layout.giveRow) while the column has one; draw.zig tagTintRange/paintPaneTag and Prompt.unlit take `.whole`; the tree.zig placement test runs under the walk default, 300 seeds) merged onto M8 (tspqtroz), resolved by meaning: no text conflict (X3's tagline, Trail, layout.giveRow and its one-line hunks in draw.zig and Prompt.zig sit beside X1's and X2's); THE ORDER X3 ASKED TO CHECK: X1 (E5.2) gives each pane of a column its width before its height in layout.compute, so that a band host's floor (floorRows: max(wantedTagRows, headRows + band)) wraps its tag at the width it will have; compute starts from zeroed rects, so in that pass a pane has `w` and `h == 0`; X3's folded reads both: on X3's own tree `w == 0` there returned before any cut (and wantedTagRows returned the last sync's rows); on the merge `h == 0` read as a pane with no rows, so a walked reading pane hosting a band had its path cut to its basename in the floor while the sync after it, with the real height, kept it whole: the floor counted fewer rows above the body than the tag took; RUN (TEST FIRST): Trail.zig "a band on a walked reading pane keeps it a body of 60 % ..." (40 columns, the reader's path some 230 cells, its tag at rest 6 rows or more; its share of the column swept from 12 rows to 30, Help with a query nothing matches, a 4-row band): fails on the merge at Trail.zig:1019, the body under 60 % of the pane (UX D6, E3); a user could have hit it on a walked reading pane with a long path in a narrow column, any band (a level, Help, a picker) opened on it; THE FIX (tagline.folded): `r.h == 0` reads as not laid out, as `r.w == 0` does: no cut, the tag at rest whole; the floor then reserves the whole tag and the sync, given at least that many rows, finds it fits: both count the same rows; where the column cannot give them, the sync cuts as X3 does; the witnesses X3 named pass: tree.zig "random placements, refused or not ..." (shell-test, filtered 8/8) and P1's Pick "after Enter the list is a word in the reader's trail ..." (core-test, filtered 11/11); core-test 1097/1268 (171 skipped: M8's 1095 + X3's test + this one), process-test 0 of 147 failed (3 skipped): no golden moved
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.zig137
1 files changed, 134 insertions, 3 deletions
diff --git a/core/Trail.zig b/core/Trail.zig
index c2c1b0c3..ddc350ca 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,129 @@ 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 "a band on a walked reading pane keeps it a body of 60 %: the layout's floor counts its tag at rest whole, as the sync after it keeps it (a pane the layout has given its width and not yet its height is never cut)" {
+ var f: Fixture = .{ .p = undefined, .tmp = undefined };
+ try f.init(60);
+ defer f.deinit();
+ const p = f.p;
+ const v = p.view();
+ 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" });
+ f.look(f.held, "rank.zig", 12);
+ f.look(v.active, deep, 2);
+ const r = v.active;
+ const pane = p.panes[r].?;
+ try std.testing.expect(reading(p, pane));
+ // Narrow: its tag at rest takes more rows than Help's head and band.
+ p.update(.{ .resize = .{ .cols = 40, .rows = 60 } });
+ p.sync();
+ try std.testing.expect(pane.tag_rows > 5);
+ const c = layout.findPane(p, r).?.col;
+ const col = v.cols[c].panes[0..v.cols[c].n];
+ try std.testing.expect(col.len > 1);
+ var rows: u16 = 0;
+ for (col) |k| rows += v.rects[k].h;
+ // Its share of the column at every height from 12 rows to 30 (its tag
+ // at rest whole); Help with a query nothing matches: a 4-row band.
+ var h: u16 = 12;
+ while (h <= 30) : (h += 1) {
+ for (col) |k| p.panes[k].?.vweight = if (k == r) @floatFromInt(h) else @as(f32, @floatFromInt(rows - h)) / @as(f32, @floatFromInt(col.len - 1));
+ layout.compute(p);
+ p.sync();
+ for ([_]u21{ ' ', '?', 'q', 'q', 'x', 'q' }) |key| p.update(.{ .key = .{ .cp = key, .text = &[_]u8{@intCast(key)} } });
+ p.sync();
+ try std.testing.expect(pane.band_rows > 0);
+ const at = v.rects[r];
+ try std.testing.expect((at.h - pane.tag_rows) * 5 >= at.h * 3);
+ p.update(.{ .key = .{ .cp = pardes.Key.escape } });
+ p.sync();
+ try std.testing.expect(pardes.TagState.hostOf(p) == 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);