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/exec.zig | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/exec.zig') diff --git a/src/exec.zig b/src/exec.zig index 1b82d2a8..84a0ad5f 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -534,9 +534,14 @@ fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize { // shown, then a soft reset (DECSTR) for the rest. if (panes.Terminal.onAlternateScreen(pane)) panes.Terminal.feedOutput(p, pane, "\x1b[?1049l"); panes.Terminal.feedOutput(p, pane, "\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l\x1b[?2004l\x1b[?25h\x1b[!p"); - var buf: [command_max + 8]u8 = undefined; - const lead = if (panes.Terminal.gridCursor(pane).x != 0) "\r\n" else ""; - panes.Terminal.feedOutput(p, pane, std.fmt.bufPrint(&buf, "{s}% {s}\r\n", .{ lead, line }) catch "%\r\n"); + // The line as it runs, its newlines the terminal's, so a multi-line + // command does not staircase. + var buf: [2 * command_max + 8]u8 = undefined; + var w = std.Io.Writer.fixed(&buf); + w.writeAll(if (panes.Terminal.gridCursor(pane).x != 0) "\r\n% " else "% ") catch {}; + for (line) |c| (if (c == '\n') w.writeAll("\r\n") else w.writeByte(c)) catch {}; + w.writeAll("\r\n") catch {}; + panes.Terminal.feedOutput(p, pane, w.buffered()); p.emit(.{ .spawn = .{ .pane = @intCast(id), .serial = pane.serial, .cwd = .from(pane.cwdSlice()) } }); noteRun(p, pane, "run", line); return id; -- cgit v1.3