diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/pardes.zig | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index e08c2f37..2b3ab796 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -7251,12 +7251,14 @@ pub const Pardes = struct { if (pane.file) |*f| panes.File.refreshContext(p, pane, f); pane.view = .{ .wrap = p.settings.wrap, .layered = p.settings.tree_context_tag_style, .body_h = p.row_metrics.body_h, .tagline_h = p.row_metrics.tagline_h, .rect_h = r.h }; // The tag takes a row per line, leaving the body one row if it - // had any; a folded pane shows its first line only. - // Measured on the stack: this runs on every event, and not + // had any; a folded pane shows its first line only. Its prefix + // is made once, on the stack: this runs on every event, and not // every event may take from the scratch arena. - var room: [2 * limits.host_path_cap + 256]u8 = undefined; - var measure = std.heap.FixedBufferAllocator.init(&room); - const lead = if (tagline.prefixIn(p, measure.allocator(), pane)) |prefix| prefix.len else |_| pane.tag_lead; + var wrap_room: [32 * 1024]u8 = undefined; + var wrap_fba = std.heap.FixedBufferAllocator.init(&wrap_room); + const wa = wrap_fba.allocator(); + const prefix: ?[]const u8 = tagline.prefixIn(p, wa, pane) catch null; + const lead = if (prefix) |made| made.len else pane.tag_lead; if (lead != pane.tag_lead) { const t = &pane.tag; const old: i32 = @intCast(pane.tag_lead); @@ -7270,24 +7272,19 @@ pub const Pardes = struct { pane.tag_lead = lead; } // A row per shown row: the tag's lines wrapped at its width. - var wrap_room: [32 * 1024]u8 = undefined; - var wrap_fba = std.heap.FixedBufferAllocator.init(&wrap_room); - const wa = wrap_fba.allocator(); var lines = std.mem.count(u8, tagline.curTail(pane), "\n") + 1; var wanted = lines; var caret_row: usize = @intCast(@max(0, pane.tag.cur_row)); - if (tagline.prefixIn(p, wa, pane)) |prefix| { - if (std.mem.concat(wa, u8, &.{ prefix, tagline.curTail(pane) })) |whole| { - if (tagline.wrapTag(wa, whole, tagline.tagWidth(p, id))) |shown| { - lines = shown.rows(); - // Collapsed, one row, as acme's Tagup sets taglines to 1 - // (plan9port text.c:786). - wanted = if (pane.tag_expanded) lines else 1; - const cur = modal.offsetAt(whole, .{ .row = caret_row, .col = @intCast(@max(0, pane.tag.cur_col)) }); - caret_row = std.mem.count(u8, shown.text[0..@min(shown.fromReal(cur), shown.text.len)], "\n"); - } else |_| {} - } else |_| {} - } else |_| {} + if (prefix) |made| wrap: { + const whole = std.mem.concat(wa, u8, &.{ made, tagline.curTail(pane) }) catch break :wrap; + const shown = tagline.wrapTag(wa, whole, tagline.tagWidth(p, id)) catch break :wrap; + lines = shown.rows(); + // Collapsed, one row, as acme's Tagup sets taglines to 1 + // (plan9port text.c:786). + wanted = if (pane.tag_expanded) lines else 1; + const cur = modal.offsetAt(whole, .{ .row = caret_row, .col = @intCast(@max(0, pane.tag.cur_col)) }); + caret_row = std.mem.count(u8, shown.text[0..@min(shown.fromReal(cur), shown.text.len)], "\n"); + } if (!pane.tag_expanded) wanted = 1; pane.tag_rows = @intCast(@min(wanted, MAX_TAG_ROWS, @max(BOX_H, r.h -| 1))); if (pane.collapsed) pane.tag_rows = BOX_H; |
