From 830e936da4aca7ea802a6a862fa40c0086defd2f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 15:26:17 -0300 Subject: A command of several lines keeps its pane's tag to one row, and the tag never panics on a longer prefix A two-line exec made a command pane whose tag prefix held the line's newline, so the tag ran to a second row and tagTintRange sliced its first row past its end: panic. acme runs a multi-line selection as one command, and so does pardes; the tag now shows the line's first row, cut at a character's start, and '...', tagTintRange stays inside the row it is given, and the '% line' echo turns the line's newlines into the terminal's, so it does not staircase. Co-Authored-By: Claude Opus 5.5 --- src/tagline.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/tagline.zig') diff --git a/src/tagline.zig b/src/tagline.zig index 14bf5677..28dffa06 100644 --- a/src/tagline.zig +++ b/src/tagline.zig @@ -112,8 +112,15 @@ pub fn pathPrefix(arena: std.mem.Allocator, pane: *Pane) ![]const u8 { return std.fmt.allocPrint(arena, "{s} [{d}/{d}]", .{ pv.path, pv.page + 1, pv.page_count }); if (pane.image) |*state| return panes.Image.tagPrefix(arena, state); // A command pane: its directory, the line it runs, and how that went. + // Its first line only, cut to 48 bytes at a character's start: a tag's + // first row is where the prefix ends, and a line that ran over to a + // second (acme runs a multi-line selection as one command) would move + // it (body_layer.zig tagTintRange). if (pane.command) |line| { - const shown = line[0..@min(line.len, 48)]; + const first = line[0 .. std.mem.indexOfAny(u8, line, "\r\n") orelse line.len]; + var cut = @min(first.len, 48); + while (cut < first.len and cut > 0 and first[cut] & 0xC0 == 0x80) cut -= 1; + const shown = first[0..cut]; const more = if (shown.len < line.len) "..." else ""; var idbuf: [48]u8 = undefined; const id = exec.replId(&idbuf, pane); -- cgit v1.3