summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/Prompt.zig2
-rw-r--r--core/Trail.zig96
-rw-r--r--core/draw.zig8
-rw-r--r--core/layout.zig31
-rw-r--r--core/ninep/tree.zig5
-rw-r--r--core/tagline.zig105
6 files changed, 213 insertions, 34 deletions
diff --git a/core/Prompt.zig b/core/Prompt.zig
index ad2cfbed..0a288a79 100644
--- a/core/Prompt.zig
+++ b/core/Prompt.zig
@@ -811,7 +811,7 @@ pub fn execWord(p: *Pardes, id: usize) void {
pub fn unlit(p: *const Pardes, pane: *Pane) ?[2]usize {
if (Trail.outOfRest(p, pane)) return null;
const t = &pane.trail;
- const whole = pardes.tagline.folded(p, pane);
+ const whole = pardes.tagline.folded(p, pane).whole;
for (t.steps[0..t.cur], 0..) |*step, i| if (step.* == .search) {
if (lights(pane, &step.search) or t.isFolded(i, whole)) return null;
return t.spanOf(i, whole);
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);
diff --git a/core/draw.zig b/core/draw.zig
index a459e3e9..9fd678e4 100644
--- a/core/draw.zig
+++ b/core/draw.zig
@@ -721,7 +721,11 @@ fn tagTintRange(p: *const Pardes, pane: *const Pane, tag: []const u8, prefix_len
} else return null;
const basename = if (std.mem.lastIndexOfScalar(u8, name, '/')) |slash| slash + 1 else 0;
if (basename == name.len) return null;
- return .{ .lo = start + basename, .hi = start + name.len };
+ // A walked file's path cut from its left: a `…` for the bytes it drops
+ // (tagline.folded), never its basename's.
+ const cut = if (pane.file != null) tagline.folded(p, pane).cut else 0;
+ const dots: usize = if (cut > 0) "…".len else 0;
+ return .{ .lo = start + dots + basename - cut, .hi = start + dots + name.len - cut };
}
/// A header or a notice band as a tag layer: `viewport.h` rows, line `top`
@@ -1118,7 +1122,7 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
const ahead = tagline.forwardSpan(p, pane);
if (ahead[0] < ahead[1]) inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, ahead[0], @min(ahead[1], first_line.len), inks.dim, false);
if (pane.file != null and pane.trail.n > 0 and !pardes.Trail.outOfRest(p, pane)) {
- const kept = tagline.folded(p, pane);
+ const kept = tagline.folded(p, pane).whole;
const t = &pane.trail;
const first: usize = @intFromBool(t.steps[0] == .owner);
if (t.isFolded(first, kept)) {
diff --git a/core/layout.zig b/core/layout.zig
index 5550ef4a..235e83e9 100644
--- a/core/layout.zig
+++ b/core/layout.zig
@@ -586,7 +586,9 @@ pub fn acmePlace(p: *Pardes, c: usize, origin: ?usize, id: usize) void {
pub const min_body_rows = 2;
/// The rows pane `id`'s tag takes at its width, wrapped as `sync` wraps
-/// it: what a placement must leave it above its body rows.
+/// it: what a placement must leave it above its body rows. A walked file's
+/// path is cut to the rows its pane has (tagline.folded): its tag never
+/// wants a row more.
pub fn wantedTagRows(p: *Pardes, id: usize) u16 {
const pane = p.panes[id] orelse return BOX_H;
if (pane.collapsed or !pane.tag_expanded) return BOX_H;
@@ -728,6 +730,33 @@ pub fn restoreMinimaFrom(p: *Pardes, before: *const [MAX_PANES]Rect, before_min:
compute(p);
}
+/// One row more for pane `id` from whichever pane of its column has the
+/// most above its own minimum, as restoreMinimaFrom gives them; false,
+/// changing nothing, when none has one (or the column holds a folded
+/// pane).
+pub fn giveRow(p: *Pardes, id: usize) bool {
+ const v = p.view();
+ compute(p);
+ const c = (findPane(p, id) orelse return false).col;
+ const col = v.cols[c].panes[0..v.cols[c].n];
+ var giver: ?usize = null;
+ var spare: u16 = 0;
+ for (col) |k| {
+ const pane = p.panes[k] orelse return false;
+ if (pane.collapsed) return false;
+ if (k != id and v.rects[k].h -| minRows(p, k) > spare) {
+ spare = v.rects[k].h - minRows(p, k);
+ giver = k;
+ }
+ }
+ const g = giver orelse return false;
+ for (col) |k| p.panes[k].?.vweight = @floatFromInt(@max(1, v.rects[k].h));
+ p.panes[g].?.vweight -= 1;
+ p.panes[id].?.vweight += 1;
+ compute(p);
+ return true;
+}
+
/// Column `c`'s rows for `id`, last in it, at its minimum: a row at a
/// time from whichever pane has the most above its own minimum, so a pane
/// dragged short keeps its rows and the others give only what they must.
diff --git a/core/ninep/tree.zig b/core/ninep/tree.zig
index 4feb0153..01cfe297 100644
--- a/core/ninep/tree.zig
+++ b/core/ninep/tree.zig
@@ -2013,11 +2013,6 @@ test "random placements, refused or not, leave no pane under its tag and two row
const rows = r.intRangeAtMost(u16, 6, 40);
const p = try pardes.Pardes.init(testing.allocator, .{ .tty_only = true, .cols = r.intRangeAtMost(u16, 60, 240), .rows = rows });
defer p.deinit();
- // Placements as a Look made them before the walk: `Jumps new-pane`
- // (SPEC §6.6). Under the walk a step in place can wrap its tag in a
- // column with no rows to give (seed 109): the trail's give-way,
- // not a placement's refusal (Trail.lift lifts it when there are).
- p.settings.jumps = .@"new-pane";
while (p.nextEffect()) |_| {}
_ = try p.setTestFile("x\n");
while (p.nextEffect()) |_| {}
diff --git a/core/tagline.zig b/core/tagline.zig
index 5f7222e6..000136c6 100644
--- a/core/tagline.zig
+++ b/core/tagline.zig
@@ -177,14 +177,17 @@ fn restPath(p: *const Pardes, arena: std.mem.Allocator, pane: *Pane) ![]const u8
const keep = pardes.Trail.reading(p, pane);
if (pane.trail.n == 0 and !keep) return name;
// Its walk's back steps before the name, its forward steps after
- // it (Trail.zig), in the room `bytes` measures them.
+ // it (Trail.zig), in the room `bytes` measures them; a name its
+ // tag has not the rows for cut from the left (`folded`).
const keep_word = if (keep) " Keep" else "";
- const whole = folded(p, pane);
- const room = try arena.alloc(u8, pane.trail.bytes(.back, whole) + name.len + pane.trail.bytes(.forward, whole) + keep_word.len);
+ const fold = folded(p, pane);
+ const dots = if (fold.cut > 0) "…" else "";
+ const room = try arena.alloc(u8, pane.trail.bytes(.back, fold.whole) + dots.len + name.len - fold.cut + pane.trail.bytes(.forward, fold.whole) + keep_word.len);
var w: std.Io.Writer = .fixed(room);
- pane.trail.write(.back, whole, &w) catch return error.OutOfMemory;
- w.writeAll(name) catch return error.OutOfMemory;
- pane.trail.write(.forward, whole, &w) catch return error.OutOfMemory;
+ pane.trail.write(.back, fold.whole, &w) catch return error.OutOfMemory;
+ w.writeAll(dots) catch return error.OutOfMemory;
+ w.writeAll(name[fold.cut..]) catch return error.OutOfMemory;
+ pane.trail.write(.forward, fold.whole, &w) catch return error.OutOfMemory;
w.writeAll(keep_word) catch return error.OutOfMemory;
return w.buffered();
}
@@ -201,26 +204,76 @@ fn restPath(p: *const Pardes, arena: std.mem.Allocator, pane: *Pane) ![]const u8
/// Where a file's name starts in its tag: after its walk's back steps.
pub fn nameAt(p: *const Pardes, pane: *const Pane) usize {
- return if (pane.file != null and pane.trail.n > 0) pane.trail.bytes(.back, folded(p, pane)) else 0;
+ return if (pane.file != null and pane.trail.n > 0) pane.trail.bytes(.back, folded(p, pane).whole) else 0;
}
+/// How a file's tag at rest writes its walk and its name (UX D8, D2).
+pub const Fold = struct {
+ /// The newest back steps written whole; older ones fold into `+N`.
+ whole: usize = pardes.Trail.shown_steps,
+ /// The bytes its name drops from its left, a `…` in their place.
+ cut: usize = 0,
+ /// Its tag, its name whole, wants more rows than its pane has over
+ /// `layout.min_body_rows`: Trail.lift grows it while its column has a
+ /// row to give.
+ squeezed: bool = false,
+};
+
/// The back steps a file's tag writes whole at rest (UX D8): the newest
/// three (Trail.shown_steps), fewer, down to the newest alone, while its
/// walk would make the tag take more rows than it takes with none: the
/// walk never adds a row to a tag at rest (as far as the newest alone
-/// lets it).
-pub fn folded(p: *const Pardes, pane: *const Pane) usize {
+/// lets it). A pane that walked (a step besides its owner and where it
+/// is) whose tag still wants more rows than the pane has over
+/// `layout.min_body_rows` keeps its newest step alone and cuts its path
+/// from the left to fit them, its basename always whole (UX D2; the
+/// coordinator's ruling on seeds 109 and 162: a step never refuses and
+/// never takes a row its column cannot give). Rows are counted in cells,
+/// as a tag at rest wraps (UX E4, P1's reading 9).
+pub fn folded(p: *const Pardes, pane: *const Pane) Fold {
const t = &pane.trail;
- const f = pane.file orelse return pardes.Trail.shown_steps;
- if (t.n == 0) return pardes.Trail.shown_steps;
- const id = panes.paneIdOf(p, pane) orelse return pardes.Trail.shown_steps;
+ const f = pane.file orelse return .{};
+ if (t.n == 0) return .{};
+ const id = panes.paneIdOf(p, pane) orelse return .{};
const tab = p.settings.tab;
const width = tagWidth(p, id);
const name = if (pane.prompt == .name) pane.input.own orelse f.path else f.path;
- const bare = panes.File.displayWidth(tab, name) + @as(usize, if (pardes.Trail.reading(p, pane)) " Keep".len else 0) + panes.File.displayWidth(tab, curTail(pane));
+ const keep = pardes.Trail.reading(p, pane);
+ const tail = curTail(pane);
+ const bare = panes.File.displayWidth(tab, name) + @as(usize, if (keep) " Keep".len else 0) + panes.File.displayWidth(tab, tail);
var whole: usize = pardes.Trail.shown_steps;
while (whole > 1 and rowsOf(bare + walkCells(t, whole, tab), width) > rowsOf(bare, width)) whole -= 1;
- return whole;
+ const r = p.view().rects[id];
+ const walked = t.n > @as(usize, @intFromBool(t.steps[0] == .owner)) + 1;
+ if (!keep or !walked or pane.prompt == .name or pane.collapsed or !pane.tag_expanded or r.w == 0) return .{ .whole = whole };
+ // Its first line: the prefix, the space restPrefix gives a tail
+ // without one, the tail's first line; and the rows its others take.
+ const first = std.mem.indexOfScalar(u8, tail, '\n') orelse tail.len;
+ var below: usize = 0;
+ if (first < tail.len) {
+ var lines = std.mem.splitScalar(u8, tail[first + 1 ..], '\n');
+ while (lines.next()) |line| below += rowsOf(panes.File.displayWidth(tab, line), width);
+ }
+ const gap: usize = @intFromBool(tail.len > 0 and std.mem.indexOfScalar(u8, " \t\n", tail[0]) == null);
+ const rest = " Keep".len + gap + panes.File.displayWidth(tab, tail[0..first]);
+ const path = panes.File.displayWidth(tab, name);
+ const rows = r.h -| layout.min_body_rows;
+ if (@min(rowsOf(walkCells(t, whole, tab) + path + rest, width) + below, pardes.MAX_TAG_ROWS) <= rows) return .{ .whole = whole };
+ // The newest step alone, then as much of the path's end as fits, after
+ // a `…` cell.
+ const room = (rows -| below) * width;
+ const used = walkCells(t, 1, tab) + rest;
+ if (used + path <= room) return .{ .whole = 1, .squeezed = true };
+ const drop = used + path + 1 - room;
+ const base = if (std.mem.lastIndexOfScalar(u8, name, '/')) |slash| slash + 1 else 0;
+ var cut: usize = 0;
+ var cells: usize = 0;
+ while (cut < base and cells < drop) {
+ const next = modal.nextGrapheme(name, cut);
+ cells += panes.File.displayWidth(tab, name[cut..next]);
+ cut = next;
+ }
+ return .{ .whole = 1, .cut = @min(cut, base), .squeezed = true };
}
/// The cells a walk's words take at rest with its newest `whole` back
@@ -241,10 +294,11 @@ fn rowsOf(cells: usize, width: usize) usize {
pub fn forwardSpan(p: *const Pardes, pane: *const Pane) [2]usize {
const f = pane.file orelse return .{ 0, 0 };
if (pane.trail.n == 0 or pardes.Trail.outOfRest(p, pane)) return .{ 0, 0 };
- const whole = folded(p, pane);
+ const fold = folded(p, pane);
const name = if (pane.prompt == .name) pane.input.own orelse f.path else f.path;
- const lo = pane.trail.bytes(.back, whole) + name.len;
- return .{ lo, lo + pane.trail.bytes(.forward, whole) };
+ const dots: usize = if (fold.cut > 0) "…".len else 0;
+ const lo = pane.trail.bytes(.back, fold.whole) + dots + name.len - fold.cut;
+ return .{ lo, lo + pane.trail.bytes(.forward, fold.whole) };
}
/// The step of pane `pane`'s walk whose word is at byte `at` of its tag's
@@ -252,7 +306,7 @@ pub fn forwardSpan(p: *const Pardes, pane: *const Pane) [2]usize {
pub fn trailAt(p: *const Pardes, pane: *const Pane, at: usize) ?u8 {
if (pane.trail.n == 0 or pane.file == null) return null;
if (pardes.Trail.outOfRest(p, pane)) return pane.trail.stepAt(.newest, 1, at);
- const whole = folded(p, pane);
+ const whole = folded(p, pane).whole;
const ahead = forwardSpan(p, pane);
if (at < nameAt(p, pane)) return pane.trail.stepAt(.back, whole, at);
if (at >= ahead[0] and at < ahead[1]) return pane.trail.stepAt(.forward, whole, at - ahead[0]);
@@ -477,10 +531,14 @@ pub fn onName(p: *const Pardes, pane: *Pane, row: usize, col: usize) ?usize {
const name = if (pane.prompt == .name) pane.input.own orelse f.path else f.path;
var room: [pardes.Trail.max_steps * (pardes.Trail.max_text + 32)]u8 = undefined;
var w: std.Io.Writer = .fixed(&room);
- pane.trail.write(.back, folded(p, pane), &w) catch return null;
+ const fold = folded(p, pane);
+ pane.trail.write(.back, fold.whole, &w) catch return null;
const lead = panes.File.displayWidth(tab, w.buffered());
- if (col < lead or col >= lead + panes.File.displayWidth(tab, name)) return null;
- return col - lead;
+ // A name cut from its left (`folded`) shows a `…` cell, then its end:
+ // the `…` is where its end starts.
+ const dots: usize = @intFromBool(fold.cut > 0);
+ if (col < lead or col >= lead + dots + panes.File.displayWidth(tab, name[fold.cut..])) return null;
+ return panes.File.displayWidth(tab, name[0..fold.cut]) + ((col - lead) -| dots);
}
/// A key typed into a saving file's path, with the tag's cursor there,
@@ -493,7 +551,10 @@ pub fn typedIntoName(p: *Pardes, pane: *Pane, key: pardes.Key) bool {
// The name starts after its walk's words.
const col: usize = @intCast(@max(0, pane.tag.cur_col));
if (col < nameAt(p, pane)) return false;
- const at = col - nameAt(p, pane);
+ // In a name cut from its left (`folded`), its end after the `…`.
+ const cut = folded(p, pane).cut;
+ const dots: usize = if (cut > 0) "…".len else 0;
+ const at = cut + ((col - nameAt(p, pane)) -| dots);
const back = key.cp == pardes.Key.backspace or pardes.hit(key, config.insert_backspace_alias);
const forward = key.cp == pardes.Key.delete or pardes.hit(key, config.insert_delete_alias);
const typed = key.text.len > 0 and !key.ctrl and !key.alt;